@ic-pay/icpay-widget 0.1.85 → 0.1.88

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/index.js CHANGED
@@ -1,4 +1,4 @@
1
- var Re=Object.defineProperty;var Te=Object.getOwnPropertyDescriptor;var s=(n,a,e,t)=>{for(var i=t>1?void 0:t?Te(a,e):a,r=n.length-1,o;r>=0;r--)(o=n[r])&&(i=(t?o(a,e,i):o(i))||i);return t&&i&&Re(a,e,i),i};import{css as Pe}from"lit";var E=Pe`
1
+ var Pe=Object.defineProperty;var $e=Object.getOwnPropertyDescriptor;var s=(n,a,e,t)=>{for(var i=t>1?void 0:t?$e(a,e):a,o=n.length-1,r;o>=0;o--)(r=n[o])&&(i=(t?r(a,e,i):r(i))||i);return t&&i&&Pe(a,e,i),i};import{css as De}from"lit";var E=De`
2
2
  :host {
3
3
  --icpay-primary: #f9fafb;
4
4
  --icpay-secondary: #e5e7eb;
@@ -13,15 +13,14 @@ var Re=Object.defineProperty;var Te=Object.getOwnPropertyDescriptor;var s=(n,a,e
13
13
  font-family: var(--icpay-font);
14
14
  }
15
15
 
16
- .card {
16
+ .icpay-card {
17
17
  background: var(--icpay-surface);
18
18
  border: 1px solid var(--icpay-border);
19
19
  border-radius: 16px;
20
20
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.35);
21
- overflow: hidden;
22
21
  }
23
22
 
24
- .section {
23
+ .icpay-section {
25
24
  padding: 20px;
26
25
  }
27
26
 
@@ -57,7 +56,7 @@ var Re=Object.defineProperty;var Te=Object.getOwnPropertyDescriptor;var s=(n,a,e
57
56
  0%, 100% { opacity: 1; }
58
57
  50% { opacity: 0.7; }
59
58
  }
60
- `;function Q(n,a){if(!n||!a)return;let e=a.primaryColor||void 0,t=a.secondaryColor||void 0,i=(Y,N)=>{N&&n.style.setProperty(Y,N)};i("--icpay-primary",e),i("--icpay-secondary",t);let r=Y=>{if(!Y)return null;let N=Y.replace("#",""),ce=N.length===3?N.split("").map(Ae=>Ae+Ae).join(""):N,de=parseInt(ce,16),pe=de>>16&255,Ne=de>>8&255,Ue=de&255;return{r:pe,g:Ne,b:Ue}},c=(Y=>{let N=r(Y);if(!N)return 0;let ce=de=>{let pe=de/255;return pe<=.03928?pe/12.92:Math.pow((pe+.055)/1.055,2.4)};return .2126*ce(N.r)+.7152*ce(N.g)+.0722*ce(N.b)})(e||t)>.6,b=a.surfaceColor||(c?"#f3f4f6":"#1f2937"),A=a.surfaceAltColor||(c?"#e5e7eb":"#374151"),ae=a.borderColor||(c?"#d1d5db":"#4b5563"),D=a.textColor||(c?"#111827":"#f9fafb"),le=a.accentColor||t||e||(c?"#6b7280":"#9ca3af"),F=a.mutedTextColor||(c?"#6b7280":"#9ca3af");i("--icpay-accent",le),i("--icpay-text",D),i("--icpay-muted",F),i("--icpay-surface",b),i("--icpay-surface-alt",A),i("--icpay-border",ae)}import{Icpay as Me}from"@ic-pay/icpay-sdk";var Oe=typeof window<"u";function ye(n,a,e){n&&(e!==void 0?console.log(`[ICPay Widget] ${a}`,e):console.log(`[ICPay Widget] ${a}`))}function d(n){if(!Oe)return{client:{},quoteUsd:async()=>({tokenAmountDecimals:"0"}),sendUsd:async()=>({transactionId:"0",status:"pending"})};ye(n.debug||!1,"Creating SDK with config:",n);let a={publishableKey:n.publishableKey};n.enableEvents!==void 0?a.enableEvents=n.enableEvents:a.enableEvents=!0,n.apiUrl&&(a.apiUrl=n.apiUrl),n.icHost&&(a.icHost=n.icHost),n.actorProvider&&(a.actorProvider=n.actorProvider),n.connectedWallet&&(a.connectedWallet=n.connectedWallet),n.debug!==void 0&&(a.debug=n.debug),ye(n.debug||!1,"Filtered SDK config:",a);try{ye(n.debug||!1,"typeof Icpay:",typeof Me);let e=new Me(a);if(Oe){let r=e,o=l=>{r.addEventListener(l,c=>{window.dispatchEvent(new CustomEvent(l,{detail:c?.detail??c}))})};["icpay-sdk-error","icpay-sdk-transaction-created","icpay-sdk-transaction-updated","icpay-sdk-transaction-completed","icpay-sdk-transaction-failed","icpay-sdk-method-start","icpay-sdk-method-success","icpay-sdk-method-error"].forEach(o)}async function t(r,o){return e.calculateTokenAmountFromUSD({usdAmount:r,ledgerCanisterId:o})}async function i(r,o,l){return e.sendFundsUsd({usdAmount:r,ledgerCanisterId:o,metadata:l})}return{client:e,quoteUsd:t,sendUsd:i}}catch(e){throw ye(n.debug||!1,"Error creating SDK:",e),e}}import{LitElement as qe,html as Z,css as Ge}from"lit";import{customElement as Ye,property as Qe,state as U}from"lit/decorators.js";import{IcpayError as Ie}from"@ic-pay/icpay-sdk";var x={WALLET_NOT_CONNECTED:"WALLET_NOT_CONNECTED",WALLET_USER_CANCELLED:"WALLET_USER_CANCELLED",WALLET_SIGNATURE_REJECTED:"WALLET_SIGNATURE_REJECTED",INSUFFICIENT_BALANCE:"INSUFFICIENT_BALANCE",NETWORK_ERROR:"NETWORK_ERROR",API_ERROR:"API_ERROR",LEDGER_NOT_FOUND:"LEDGER_NOT_FOUND",TRANSACTION_FAILED:"TRANSACTION_FAILED",TRANSACTION_TIMEOUT:"TRANSACTION_TIMEOUT",UNKNOWN_ERROR:"UNKNOWN_ERROR"},Ke={onError:n=>{console.error("[ICPay Widget] Error:",n)},onUserCancelled:()=>{console.log("[ICPay Widget] User cancelled the action")},onInsufficientBalance:n=>{console.warn("[ICPay Widget] Insufficient balance:",n.message)},onWalletError:n=>{console.warn("[ICPay Widget] Wallet error:",n.message)},onNetworkError:n=>{console.error("[ICPay Widget] Network error:",n.message)}};function S(n,a=Ke){n instanceof Ie?(a.onError(n),n.isUserCancelled()?a.onUserCancelled?.():n.isBalanceError()?a.onInsufficientBalance?.(n):n.isWalletError()?a.onWalletError?.(n):n.isNetworkError()&&a.onNetworkError?.(n)):(console.error("[ICPay Widget] Unknown error:",n),a.onError(new Ie({code:x.UNKNOWN_ERROR,message:n instanceof Error?n.message:"An unknown error occurred",details:n})))}var Be={[x.WALLET_NOT_CONNECTED]:"Please connect your wallet to continue",[x.WALLET_USER_CANCELLED]:"User have rejected the transfer",[x.WALLET_SIGNATURE_REJECTED]:"User have rejected the transfer",[x.INSUFFICIENT_BALANCE]:"Insufficient balance for this transaction",[x.NETWORK_ERROR]:"Network error. Please try again",[x.API_ERROR]:"Service temporarily unavailable",[x.LEDGER_NOT_FOUND]:"Selected token is not supported",[x.TRANSACTION_FAILED]:"Transaction failed. Please try again",[x.TRANSACTION_TIMEOUT]:"Transaction timed out. Please try again",[x.UNKNOWN_ERROR]:"Something went wrong. Please try again"};function k(n){return Be[n.code]||n.message||"An error occurred"}function W(n){return!n.isUserCancelled()}function C(n){if(n.userAction)return n.userAction;switch(n.code){case x.WALLET_NOT_CONNECTED:return"Connect Wallet";case x.INSUFFICIENT_BALANCE:return"Add Funds";case x.NETWORK_ERROR:case x.API_ERROR:return"Try Again";default:return null}}function L(n){return n.isUserCancelled()?"info":n.isBalanceError()||n.isWalletError()?"warning":"error"}import{LitElement as De,html as y,css as Fe}from"lit";import{customElement as _e,property as X,state as T}from"lit/decorators.js";var je=[{key:"wallet",label:"Connect Wallet",tooltip:"Awaiting wallet connection",status:"pending"},{key:"init",label:"Initialising ICPay",tooltip:"Initializing payment",status:"pending"},{key:"await",label:"Awaiting payment confirmation",tooltip:"Preparing payment",status:"pending"},{key:"transfer",label:"Transferring funds",tooltip:"Submitting payment",status:"pending"},{key:"verify",label:"Verifying payment",tooltip:"Confirming payment",status:"pending"},{key:"confirm",label:"Payment confirmed",tooltip:"Payment completed",status:"pending"}],p=class extends De{constructor(){super(...arguments);this.open=!1;this.steps=je;this.amount=0;this.currency="";this.ledgerSymbol="";this.activeIndex=0;this.completed=!1;this.failed=!1;this.errorMessage=null;this.showSuccess=!1;this.showConfetti=!1;this.currentSteps=[];this.currentAmount=0;this.currentCurrency="";this.currentLedgerSymbol="";this.progressionTimer=null;this.onMethodStart=e=>{let t=e?.detail?.name||"",i=e?.detail?.type||"";console.log("ICPay Progress: Method start event received:",e.detail),(t==="sendFunds"||t==="sendFundsUsd"||t==="sendUsd"||t==="pay"||t==="unlock"||t==="tip"||t==="donate"||t==="order")&&(this.open=!0,this.activeIndex=0,this.completed=!1,this.failed=!1,this.errorMessage=null,this.showSuccess=!1,this.showConfetti=!1,this.currentSteps=this.currentSteps.map(r=>({...r,status:"pending"})),this.setLoadingByKey("wallet"),e?.detail?.amount!==void 0&&(this.currentAmount=e.detail.amount,this.amount=e.detail.amount,console.log("ICPay Progress: Amount updated to:",e.detail.amount)),e?.detail?.currency&&(this.currentCurrency=e.detail.currency,this.currency=e.detail.currency,console.log("ICPay Progress: Currency updated to:",e.detail.currency)),e?.detail?.ledgerSymbol&&(this.currentLedgerSymbol=e.detail.ledgerSymbol,this.ledgerSymbol=e.detail.ledgerSymbol,console.log("ICPay Progress: Current state after method start:",{activeIndex:this.activeIndex,currentAmount:this.currentAmount,currentCurrency:this.currentCurrency,currentLedgerSymbol:this.currentLedgerSymbol})),console.log("ICPay Progress: Waiting for wallet confirmation before starting progression"),this.requestUpdate()),!this.failed&&!this.completed&&(t==="sendFundsToLedger"?(this.completeByKey("wallet"),this.completeByKey("init"),this.completeByKey("await"),this.setLoadingByKey("transfer")):t==="notifyLedgerTransaction"&&(this.completeByKey("wallet"),this.completeByKey("init"),this.completeByKey("await"),this.completeByKey("transfer"),this.setLoadingByKey("verify")))};this.onMethodSuccess=e=>{let t=e?.detail?.name||"";(t==="sendFunds"||t==="sendFundsUsd"||t==="sendUsd"||t==="pay"||t==="unlock"||t==="tip"||t==="donate"||t==="order")&&(this.dispatchEvent(new CustomEvent("icpay-progress-method-success",{detail:{methodName:t,step:this.activeIndex},bubbles:!0})),!this.failed&&!this.completed&&(t==="getLedgerBalance"?(this.completeByKey("wallet"),this.completeByKey("init"),this.setLoadingByKey("await")):t==="sendFundsToLedger"?(this.completeByKey("wallet"),this.completeByKey("init"),this.completeByKey("await"),this.completeByKey("transfer"),this.setLoadingByKey("verify")):t==="notifyLedgerTransaction"&&(this.completeByKey("wallet"),this.completeByKey("init"),this.completeByKey("await"),this.completeByKey("transfer"),this.completeByKey("verify"),this.setLoadingByKey("confirm"))))};this.onTransactionCreated=e=>{let t=e?.detail?.transactionId||e?.detail?.id;console.log("ICPay Progress: Transaction created event received:",e.detail),!this.failed&&!this.completed&&(this.completeByKey("wallet"),this.completeByKey("init"),this.completeByKey("await"),this.setLoadingByKey("transfer")),this.dispatchEvent(new CustomEvent("icpay-progress-transaction-created",{detail:{transactionId:t,step:this.activeIndex},bubbles:!0}))};this.onTransactionUpdated=e=>{let t=e?.detail?.status||"pending",i=e?.detail?.transactionId||e?.detail?.id;console.log("ICPay Progress: Transaction updated event received:",e.detail),!this.failed&&this.completed,this.dispatchEvent(new CustomEvent("icpay-progress-transaction-updated",{detail:{status:t,transactionId:i,step:this.activeIndex},bubbles:!0}))};this.onTransactionCompleted=e=>{let t=e?.detail?.transactionId||e?.detail?.id,i=e?.detail?.status||"completed";console.log("ICPay Progress: Transaction completed event received:",e.detail),console.log("ICPay Progress: Current state when transaction completed:",{activeIndex:this.activeIndex,completed:this.completed,failed:this.failed,showSuccess:this.showSuccess}),this.completeByKey("transfer"),this.completeByKey("await"),this.completeByKey("init"),this.completeByKey("verify"),this.completeByKey("confirm"),this.completed=!0,this.showSuccess=!0,this.showConfetti=!0,this.dispatchEvent(new CustomEvent("icpay-progress-completed",{detail:{transactionId:t,status:i,amount:this.currentAmount||this.amount,currency:this.currentCurrency||this.currency,ledgerSymbol:this.currentLedgerSymbol||this.ledgerSymbol},bubbles:!0})),setTimeout(()=>{this.open&&this.showSuccess&&!this.failed&&(this.open=!1)},2e3),setTimeout(()=>{this.showConfetti=!1},3e3)};this.onTransactionFailed=e=>{let t=e?.detail?.message||e?.detail?.error?.message||"Transaction failed",i=e?.detail?.error?.code||e?.detail?.code||"UNKNOWN_ERROR",r=e?.detail?.transactionId||e?.detail?.id;console.log("ICPay Progress: Transaction failed event received:",e.detail),this.failed=!0,this.errorMessage=this.transformErrorMessage(t),this.showSuccess=!1,this.updateStepStatus(this.activeIndex,"error",t),this.stopAutomaticProgression(),this.open=!0,this.dispatchEvent(new CustomEvent("icpay-progress-failed",{detail:{errorMessage:t,errorCode:i,transactionId:r,step:this.activeIndex},bubbles:!0}))};this.onMethodError=e=>{let t=e?.detail?.name||"",i=e?.detail?.error?.message||e?.detail?.message||"An error occurred",r=e?.detail?.error?.code||e?.detail?.code||"METHOD_ERROR";console.log("ICPay Progress: Method error event received:",e.detail),(t?.startsWith("sendFunds")||t==="sendUsd"||t==="pay"||t==="unlock"||t==="tip"||t==="donate"||t==="order")&&(this.failed=!0,this.errorMessage=this.transformErrorMessage(i),this.showSuccess=!1,this.updateStepStatus(this.activeIndex,"error",i),this.stopAutomaticProgression(),this.open=!0,this.dispatchEvent(new CustomEvent("icpay-progress-error",{detail:{methodName:t,errorMessage:i,errorCode:r,step:this.activeIndex},bubbles:!0})))};this.onSDKError=e=>{let t=e?.detail?.message||"SDK error occurred",i=e?.detail?.code||"SDK_ERROR";console.log("ICPay Progress: SDK error event received:",e.detail),this.failed=!0,this.errorMessage=this.transformErrorMessage(t),this.showSuccess=!1,this.updateStepStatus(this.activeIndex,"error",t),this.stopAutomaticProgression(),this.open=!0,this.dispatchEvent(new CustomEvent("icpay-progress-sdk-error",{detail:{errorMessage:t,errorCode:i,step:this.activeIndex},bubbles:!0}))};this.onWalletConnected=e=>{let t=e?.detail?.walletType||"unknown";console.log("ICPay Progress: Wallet connected event received:",e.detail),this.completeByKey("wallet"),this.setLoadingByKey("init"),this.dispatchEvent(new CustomEvent("icpay-progress-wallet-connected",{detail:{walletType:t,step:this.activeIndex},bubbles:!0}))};this.onWalletDisconnected=e=>{let t=e?.detail?.walletType||"unknown";console.log("ICPay Progress: Wallet disconnected event received:",e.detail),this.dispatchEvent(new CustomEvent("icpay-progress-wallet-disconnected",{detail:{walletType:t,step:this.activeIndex},bubbles:!0}))};this.onBalanceCheck=e=>{let t=e?.detail?.hasBalance||!1,i=e?.detail?.balance||0;console.log("ICPay Progress: Balance check event received:",e.detail),t||(this.failed=!0,this.errorMessage="Insufficient balance for transaction",this.updateStepStatus(this.activeIndex,"error","Insufficient balance for transaction"),this.stopAutomaticProgression(),this.dispatchEvent(new CustomEvent("icpay-progress-insufficient-balance",{detail:{balance:i,required:this.currentAmount||this.amount,step:this.activeIndex},bubbles:!0})))};this.onLedgerVerified=e=>{let t=e?.detail?.ledgerId||e?.detail?.canisterId,i=e?.detail?.symbol||"unknown";console.log("ICPay Progress: Ledger verified event received:",e.detail),i&&i!=="unknown"&&(this.currentLedgerSymbol=i,this.ledgerSymbol=i),this.dispatchEvent(new CustomEvent("icpay-progress-ledger-verified",{detail:{ledgerId:t,symbol:i,step:this.activeIndex},bubbles:!0}))};this.onWidgetPayment=e=>{let t=e?.detail?.amount,i=e?.detail?.currency,r=e?.detail?.ledgerSymbol;if(console.log("ICPay Progress: Widget payment event received:",e.detail),t!==void 0&&(this.currentAmount=t,this.amount=t),i&&(this.currentCurrency=i,this.currency=i),r&&(this.currentLedgerSymbol=r,this.ledgerSymbol=r),!this.failed){for(let o=this.activeIndex;o<this.currentSteps.length;o++)this.updateStepStatus(o,"completed");this.activeIndex=this.currentSteps.length-1,this.completed=!0,this.showSuccess=!0,this.showConfetti=!0}this.dispatchEvent(new CustomEvent("icpay-progress-widget-payment",{detail:{amount:t,currency:i,ledgerSymbol:r,step:this.activeIndex},bubbles:!0}))};this.onWidgetError=e=>{let t=e?.detail?.message||"Widget error occurred",i=e?.detail?.code||"WIDGET_ERROR";console.log("ICPay Progress: Widget error event received:",e.detail),this.failed=!0,this.errorMessage=this.transformErrorMessage(t),this.showSuccess=!1,this.updateStepStatus(this.activeIndex,"error",t),this.stopAutomaticProgression(),this.open=!0,this.dispatchEvent(new CustomEvent("icpay-progress-widget-error",{detail:{errorMessage:t,errorCode:i,step:this.activeIndex},bubbles:!0}))};this.onWidgetUnlock=e=>{let t=e?.detail?.amount,i=e?.detail?.currency;if(console.log("ICPay Progress: Widget unlock event received:",e.detail),!this.failed){for(let r=this.activeIndex;r<this.currentSteps.length;r++)this.updateStepStatus(r,"completed");this.activeIndex=this.currentSteps.length-1,this.completed=!0,this.showSuccess=!0,this.showConfetti=!0}this.dispatchEvent(new CustomEvent("icpay-progress-widget-unlock",{detail:{amount:t,currency:i,step:this.activeIndex},bubbles:!0}))};this.onWidgetTip=e=>{let t=e?.detail?.amount,i=e?.detail?.currency;if(console.log("ICPay Progress: Widget tip event received:",e.detail),!this.failed){for(let r=this.activeIndex;r<this.currentSteps.length;r++)this.updateStepStatus(r,"completed");this.activeIndex=this.currentSteps.length-1,this.completed=!0,this.showSuccess=!0,this.showConfetti=!0}this.dispatchEvent(new CustomEvent("icpay-progress-widget-tip",{detail:{amount:t,currency:i,step:this.activeIndex},bubbles:!0}))};this.onWidgetDonation=e=>{let t=e?.detail?.amount,i=e?.detail?.currency;if(console.log("ICPay Progress: Widget donation event received:",e.detail),!this.failed){for(let r=this.activeIndex;r<this.currentSteps.length;r++)this.updateStepStatus(r,"completed");this.activeIndex=this.currentSteps.length-1,this.completed=!0,this.showSuccess=!0,this.showConfetti=!0}this.dispatchEvent(new CustomEvent("icpay-progress-widget-donation",{detail:{amount:t,currency:i,step:this.activeIndex},bubbles:!0}))};this.onWidgetCoffee=e=>{let t=e?.detail?.amount,i=e?.detail?.currency;if(console.log("ICPay Progress: Widget coffee event received:",e.detail),!this.failed){for(let r=this.activeIndex;r<this.currentSteps.length;r++)this.updateStepStatus(r,"completed");this.activeIndex=this.currentSteps.length-1,this.completed=!0,this.showSuccess=!0,this.showConfetti=!0}this.dispatchEvent(new CustomEvent("icpay-progress-widget-coffee",{detail:{amount:t,currency:i,step:this.activeIndex},bubbles:!0}))}}connectedCallback(){super.connectedCallback();try{Q(this,this.theme)}catch{}this.currentSteps=[...this.steps],this.currentAmount=this.amount,this.currentCurrency=this.currency,this.currentLedgerSymbol=this.ledgerSymbol,this.attachSDKEventListeners()}disconnectedCallback(){super.disconnectedCallback(),this.detachSDKEventListeners(),this.stopAutomaticProgression()}updated(e){if(e.has("theme"))try{Q(this,this.theme)}catch{}}attachSDKEventListeners(){window.addEventListener("icpay-sdk-method-start",this.onMethodStart),window.addEventListener("icpay-sdk-method-success",this.onMethodSuccess),window.addEventListener("icpay-sdk-method-error",this.onMethodError),window.addEventListener("icpay-sdk-transaction-created",this.onTransactionCreated),window.addEventListener("icpay-sdk-transaction-updated",this.onTransactionUpdated),window.addEventListener("icpay-sdk-transaction-completed",this.onTransactionCompleted),window.addEventListener("icpay-sdk-transaction-failed",this.onTransactionFailed),window.addEventListener("icpay-sdk-error",this.onSDKError),window.addEventListener("icpay-sdk-wallet-connected",this.onWalletConnected),window.addEventListener("icpay-sdk-wallet-disconnected",this.onWalletDisconnected),window.addEventListener("icpay-sdk-balance-check",this.onBalanceCheck),window.addEventListener("icpay-sdk-ledger-verified",this.onLedgerVerified),window.addEventListener("icpay-pay",this.onWidgetPayment),window.addEventListener("icpay-error",this.onWidgetError),window.addEventListener("icpay-unlock",this.onWidgetUnlock),window.addEventListener("icpay-tip",this.onWidgetTip),window.addEventListener("icpay-donation",this.onWidgetDonation),window.addEventListener("icpay-coffee",this.onWidgetCoffee)}detachSDKEventListeners(){window.removeEventListener("icpay-sdk-method-start",this.onMethodStart),window.removeEventListener("icpay-sdk-method-success",this.onMethodSuccess),window.removeEventListener("icpay-sdk-method-error",this.onMethodError),window.removeEventListener("icpay-sdk-transaction-created",this.onTransactionCreated),window.removeEventListener("icpay-sdk-transaction-updated",this.onTransactionUpdated),window.removeEventListener("icpay-sdk-transaction-completed",this.onTransactionCompleted),window.removeEventListener("icpay-sdk-transaction-failed",this.onTransactionFailed),window.removeEventListener("icpay-sdk-error",this.onSDKError),window.removeEventListener("icpay-sdk-wallet-connected",this.onWalletConnected),window.removeEventListener("icpay-sdk-wallet-disconnected",this.onWalletDisconnected),window.removeEventListener("icpay-sdk-balance-check",this.onBalanceCheck),window.removeEventListener("icpay-sdk-ledger-verified",this.onLedgerVerified),window.removeEventListener("icpay-pay",this.onWidgetPayment),window.removeEventListener("icpay-error",this.onWidgetError),window.removeEventListener("icpay-unlock",this.onWidgetUnlock),window.removeEventListener("icpay-tip",this.onWidgetTip),window.removeEventListener("icpay-donation",this.onWidgetDonation),window.removeEventListener("icpay-coffee",this.onWidgetCoffee)}startAutomaticProgression(){this.progressionTimer&&clearInterval(this.progressionTimer),this.activeIndex=1,this.updateStepStatus(this.activeIndex,"loading"),console.log("ICPay Progress: Starting automatic progression from step:",this.activeIndex),this.progressionTimer=setInterval(()=>{if(this.failed||this.completed){this.stopAutomaticProgression();return}console.log("ICPay Progress: Processing step:",this.activeIndex),this.updateStepStatus(this.activeIndex,"completed"),this.activeIndex<this.currentSteps.length-1?(this.activeIndex++,this.updateStepStatus(this.activeIndex,"loading"),console.log("ICPay Progress: Auto-progressed to step:",this.activeIndex)):(this.stopAutomaticProgression(),console.log("ICPay Progress: All steps completed, waiting for transaction completion")),this.requestUpdate()},3e3)}stopAutomaticProgression(){this.progressionTimer&&(clearInterval(this.progressionTimer),this.progressionTimer=null)}updateStepStatus(e,t,i){if(e>=0&&e<this.currentSteps.length){let r=this.currentSteps[e],o=r.status;r.status=t,t==="completed"&&(r.timestamp=this.getCurrentTime()),t==="error"&&i&&(r.errorMessage=this.transformErrorMessage(i)),console.log(`ICPay Progress: Step ${e} (${r.label}) status changed from ${o} to ${t}`),this.requestUpdate()}}getCurrentTime(){return new Date().toLocaleTimeString("en-US",{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"})}progressPercent(){if(this.failed)return 0;if(this.showSuccess)return 100;let t=this.currentSteps.filter(i=>i.status==="completed").length/this.currentSteps.length*100;return Math.max(0,Math.min(100,t))}verticalPercent(){if(this.failed)return 0;if(this.showSuccess)return 100;let t=this.currentSteps.filter(i=>i.status==="completed").length/this.currentSteps.length*100;return Math.max(0,Math.min(100,t))}getStepIcon(e){switch(e.status){case"loading":return y`<div class="spinner"></div>`;case"completed":return"\u2713";case"error":return"\u2717";default:return"\u25CB"}}getStepIndexByKey(e){return this.currentSteps.findIndex(t=>t.key===e)}setLoadingByKey(e){let t=this.getStepIndexByKey(e);t>=0&&(this.activeIndex=t,this.updateStepStatus(t,"loading"))}completeByKey(e){let t=this.getStepIndexByKey(e);t>=0&&(this.updateStepStatus(t,"completed"),this.activeIndex=t)}transformErrorMessage(e){let t=String(e||"").toLowerCase();return t.includes("user rejected")||t.includes("user cancelled")||t.includes("user canceled")||t.includes("signature rejected")?"User have rejected the transfer":e}renderConfetti(){if(!this.showConfetti)return"";let e=Array.from({length:50},(i,r)=>r),t=["#0066FF","#ef4444","#10b981","#f59e0b","#8b5cf6"];return y`
59
+ `;function Q(n,a){if(!n||!a)return;let e=a.primaryColor||void 0,t=a.secondaryColor||void 0,i=(q,R)=>{R&&n.style.setProperty(q,R)};i("--icpay-primary",e),i("--icpay-secondary",t);let o=q=>{if(!q)return null;let R=q.replace("#",""),pe=R.length===3?R.split("").map(Me=>Me+Me).join(""):R,ge=parseInt(pe,16),he=ge>>16&255,Re=ge>>8&255,Ue=ge&255;return{r:he,g:Re,b:Ue}},c=(q=>{let R=o(q);if(!R)return 0;let pe=ge=>{let he=ge/255;return he<=.03928?he/12.92:Math.pow((he+.055)/1.055,2.4)};return .2126*pe(R.r)+.7152*pe(R.g)+.0722*pe(R.b)})(e||t)>.6,m=a.surfaceColor||(c?"#f3f4f6":"#1f2937"),O=a.surfaceAltColor||(c?"#e5e7eb":"#374151"),ce=a.borderColor||(c?"#d1d5db":"#4b5563"),B=a.textColor||(c?"#111827":"#f9fafb"),de=a.accentColor||t||e||(c?"#6b7280":"#9ca3af"),K=a.mutedTextColor||(c?"#6b7280":"#9ca3af");i("--icpay-accent",de),i("--icpay-text",B),i("--icpay-muted",K),i("--icpay-surface",m),i("--icpay-surface-alt",O),i("--icpay-border",ce)}import{Icpay as Oe}from"@ic-pay/icpay-sdk";var Ie=typeof window<"u";function ye(n,a,e){n&&(e!==void 0?console.log(`[ICPay Widget] ${a}`,e):console.log(`[ICPay Widget] ${a}`))}function d(n){if(!Ie)return{client:{},quoteUsd:async()=>({tokenAmountDecimals:"0"}),sendUsd:async()=>({transactionId:"0",status:"pending"})};ye(n.debug||!1,"Creating SDK with config:",n);let a={publishableKey:n.publishableKey};n.enableEvents!==void 0?a.enableEvents=n.enableEvents:a.enableEvents=!0,n.apiUrl&&(a.apiUrl=n.apiUrl),n.icHost&&(a.icHost=n.icHost),n.actorProvider&&(a.actorProvider=n.actorProvider),n.connectedWallet&&(a.connectedWallet=n.connectedWallet),n.debug!==void 0&&(a.debug=n.debug),ye(n.debug||!1,"Filtered SDK config:",a);try{ye(n.debug||!1,"typeof Icpay:",typeof Oe);let e=new Oe(a);if(Ie){let o=e,r=l=>{o.addEventListener(l,c=>{window.dispatchEvent(new CustomEvent(l,{detail:c?.detail??c}))})};["icpay-sdk-error","icpay-sdk-transaction-created","icpay-sdk-transaction-updated","icpay-sdk-transaction-completed","icpay-sdk-transaction-failed","icpay-sdk-method-start","icpay-sdk-method-success","icpay-sdk-method-error"].forEach(r)}async function t(o,r){return e.calculateTokenAmountFromUSD({usdAmount:o,ledgerCanisterId:r})}async function i(o,r,l){return e.sendFundsUsd({usdAmount:o,ledgerCanisterId:r,metadata:l})}return{client:e,quoteUsd:t,sendUsd:i}}catch(e){throw ye(n.debug||!1,"Error creating SDK:",e),e}}import{LitElement as Je,html as ee,css as Xe}from"lit";import{customElement as qe,property as Qe,state as U}from"lit/decorators.js";import{IcpayError as Ne}from"@ic-pay/icpay-sdk";var x={WALLET_NOT_CONNECTED:"WALLET_NOT_CONNECTED",WALLET_USER_CANCELLED:"WALLET_USER_CANCELLED",WALLET_SIGNATURE_REJECTED:"WALLET_SIGNATURE_REJECTED",INSUFFICIENT_BALANCE:"INSUFFICIENT_BALANCE",NETWORK_ERROR:"NETWORK_ERROR",API_ERROR:"API_ERROR",LEDGER_NOT_FOUND:"LEDGER_NOT_FOUND",TRANSACTION_FAILED:"TRANSACTION_FAILED",TRANSACTION_TIMEOUT:"TRANSACTION_TIMEOUT",UNKNOWN_ERROR:"UNKNOWN_ERROR"},ze={onError:n=>{console.error("[ICPay Widget] Error:",n)},onUserCancelled:()=>{console.log("[ICPay Widget] User cancelled the action")},onInsufficientBalance:n=>{console.warn("[ICPay Widget] Insufficient balance:",n.message)},onWalletError:n=>{console.warn("[ICPay Widget] Wallet error:",n.message)},onNetworkError:n=>{console.error("[ICPay Widget] Network error:",n.message)}};function S(n,a=ze){n instanceof Ne?(a.onError(n),n.isUserCancelled()?a.onUserCancelled?.():n.isBalanceError()?a.onInsufficientBalance?.(n):n.isWalletError()?a.onWalletError?.(n):n.isNetworkError()&&a.onNetworkError?.(n)):(console.error("[ICPay Widget] Unknown error:",n),a.onError(new Ne({code:x.UNKNOWN_ERROR,message:n instanceof Error?n.message:"An unknown error occurred",details:n})))}var Be={[x.WALLET_NOT_CONNECTED]:"Please connect your wallet to continue",[x.WALLET_USER_CANCELLED]:"User have rejected the transfer",[x.WALLET_SIGNATURE_REJECTED]:"User have rejected the transfer",[x.INSUFFICIENT_BALANCE]:"Insufficient balance for this transaction",[x.NETWORK_ERROR]:"Network error. Please try again",[x.API_ERROR]:"Service temporarily unavailable",[x.LEDGER_NOT_FOUND]:"Selected token is not supported",[x.TRANSACTION_FAILED]:"Transaction failed. Please try again",[x.TRANSACTION_TIMEOUT]:"Transaction timed out. Please try again",[x.UNKNOWN_ERROR]:"Something went wrong. Please try again"};function k(n){return Be[n.code]||n.message||"An error occurred"}function W(n){return!n.isUserCancelled()}function L(n){if(n.userAction)return n.userAction;switch(n.code){case x.WALLET_NOT_CONNECTED:return"Connect Wallet";case x.INSUFFICIENT_BALANCE:return"Add Funds";case x.NETWORK_ERROR:case x.API_ERROR:return"Try Again";default:return null}}function A(n){return n.isUserCancelled()?"info":n.isBalanceError()||n.isWalletError()?"warning":"error"}import{LitElement as Ke,html as y,css as Fe}from"lit";import{customElement as Ve,property as _,state as $}from"lit/decorators.js";var je=[{key:"wallet",label:"Connect Wallet",tooltip:"Awaiting wallet connection",status:"pending"},{key:"init",label:"Initialising ICPay",tooltip:"Initializing payment",status:"pending"},{key:"await",label:"Awaiting payment confirmation",tooltip:"Preparing payment",status:"pending"},{key:"transfer",label:"Transferring funds",tooltip:"Submitting payment",status:"pending"},{key:"verify",label:"Verifying payment",tooltip:"Confirming payment",status:"pending"},{key:"confirm",label:"Payment confirmed",tooltip:"Payment completed",status:"pending"}],p=class extends Ke{constructor(){super(...arguments);this.open=!1;this.steps=je;this.amount=0;this.currency="";this.ledgerSymbol="";this.activeIndex=0;this.completed=!1;this.failed=!1;this.errorMessage=null;this.showSuccess=!1;this.showConfetti=!1;this.currentSteps=[];this.currentAmount=0;this.currentCurrency="";this.currentLedgerSymbol="";this.progressionTimer=null;this.onMethodStart=e=>{let t=e?.detail?.name||"",i=e?.detail?.type||"";console.log("ICPay Progress: Method start event received:",e.detail),(t==="sendFunds"||t==="sendFundsUsd"||t==="sendUsd"||t==="pay"||t==="unlock"||t==="tip"||t==="donate"||t==="order")&&(this.open=!0,this.activeIndex=0,this.completed=!1,this.failed=!1,this.errorMessage=null,this.showSuccess=!1,this.showConfetti=!1,this.currentSteps=this.currentSteps.map(o=>({...o,status:"pending"})),this.setLoadingByKey("wallet"),e?.detail?.amount!==void 0&&(this.currentAmount=e.detail.amount,this.amount=e.detail.amount,console.log("ICPay Progress: Amount updated to:",e.detail.amount)),e?.detail?.currency&&(this.currentCurrency=e.detail.currency,this.currency=e.detail.currency,console.log("ICPay Progress: Currency updated to:",e.detail.currency)),e?.detail?.ledgerSymbol&&(this.currentLedgerSymbol=e.detail.ledgerSymbol,this.ledgerSymbol=e.detail.ledgerSymbol,console.log("ICPay Progress: Current state after method start:",{activeIndex:this.activeIndex,currentAmount:this.currentAmount,currentCurrency:this.currentCurrency,currentLedgerSymbol:this.currentLedgerSymbol})),console.log("ICPay Progress: Waiting for wallet confirmation before starting progression"),this.requestUpdate()),!this.failed&&!this.completed&&(t==="sendFundsToLedger"?(this.completeByKey("wallet"),this.completeByKey("init"),this.completeByKey("await"),this.setLoadingByKey("transfer")):t==="notifyLedgerTransaction"&&(this.completeByKey("wallet"),this.completeByKey("init"),this.completeByKey("await"),this.completeByKey("transfer"),this.setLoadingByKey("verify")))};this.onMethodSuccess=e=>{let t=e?.detail?.name||"";(t==="sendFunds"||t==="sendFundsUsd"||t==="sendUsd"||t==="pay"||t==="unlock"||t==="tip"||t==="donate"||t==="order")&&(this.dispatchEvent(new CustomEvent("icpay-progress-method-success",{detail:{methodName:t,step:this.activeIndex},bubbles:!0})),!this.failed&&!this.completed&&(t==="getLedgerBalance"?(this.completeByKey("wallet"),this.completeByKey("init"),this.setLoadingByKey("await")):t==="sendFundsToLedger"?(this.completeByKey("wallet"),this.completeByKey("init"),this.completeByKey("await"),this.completeByKey("transfer"),this.setLoadingByKey("verify")):t==="notifyLedgerTransaction"&&(this.completeByKey("wallet"),this.completeByKey("init"),this.completeByKey("await"),this.completeByKey("transfer"),this.completeByKey("verify"),this.setLoadingByKey("confirm"))))};this.onTransactionCreated=e=>{let t=e?.detail?.transactionId||e?.detail?.id;console.log("ICPay Progress: Transaction created event received:",e.detail),!this.failed&&!this.completed&&(this.completeByKey("wallet"),this.completeByKey("init"),this.completeByKey("await"),this.setLoadingByKey("transfer")),this.dispatchEvent(new CustomEvent("icpay-progress-transaction-created",{detail:{transactionId:t,step:this.activeIndex},bubbles:!0}))};this.onTransactionUpdated=e=>{let t=e?.detail?.status||"pending",i=e?.detail?.transactionId||e?.detail?.id;console.log("ICPay Progress: Transaction updated event received:",e.detail),!this.failed&&this.completed,this.dispatchEvent(new CustomEvent("icpay-progress-transaction-updated",{detail:{status:t,transactionId:i,step:this.activeIndex},bubbles:!0}))};this.onTransactionCompleted=e=>{let t=e?.detail?.transactionId||e?.detail?.id,i=e?.detail?.status||"completed";console.log("ICPay Progress: Transaction completed event received:",e.detail),console.log("ICPay Progress: Current state when transaction completed:",{activeIndex:this.activeIndex,completed:this.completed,failed:this.failed,showSuccess:this.showSuccess}),this.completeByKey("transfer"),this.completeByKey("await"),this.completeByKey("init"),this.completeByKey("verify"),this.completeByKey("confirm"),this.completed=!0,this.showSuccess=!0,this.showConfetti=!0,this.dispatchEvent(new CustomEvent("icpay-progress-completed",{detail:{transactionId:t,status:i,amount:this.currentAmount||this.amount,currency:this.currentCurrency||this.currency,ledgerSymbol:this.currentLedgerSymbol||this.ledgerSymbol},bubbles:!0})),setTimeout(()=>{this.open&&this.showSuccess&&!this.failed&&(this.open=!1)},2e3),setTimeout(()=>{this.showConfetti=!1},3e3)};this.onTransactionFailed=e=>{let t=e?.detail?.message||e?.detail?.error?.message||"Transaction failed",i=e?.detail?.error?.code||e?.detail?.code||"UNKNOWN_ERROR",o=e?.detail?.transactionId||e?.detail?.id;console.log("ICPay Progress: Transaction failed event received:",e.detail),this.failed=!0,this.errorMessage=this.transformErrorMessage(t),this.showSuccess=!1,this.updateStepStatus(this.activeIndex,"error",t),this.stopAutomaticProgression(),this.open=!0,this.dispatchEvent(new CustomEvent("icpay-progress-failed",{detail:{errorMessage:t,errorCode:i,transactionId:o,step:this.activeIndex},bubbles:!0}))};this.onMethodError=e=>{let t=e?.detail?.name||"",i=e?.detail?.error?.message||e?.detail?.message||"An error occurred",o=e?.detail?.error?.code||e?.detail?.code||"METHOD_ERROR";console.log("ICPay Progress: Method error event received:",e.detail),(t?.startsWith("sendFunds")||t==="sendUsd"||t==="pay"||t==="unlock"||t==="tip"||t==="donate"||t==="order")&&(this.failed=!0,this.errorMessage=this.transformErrorMessage(i),this.showSuccess=!1,this.updateStepStatus(this.activeIndex,"error",i),this.stopAutomaticProgression(),this.open=!0,this.dispatchEvent(new CustomEvent("icpay-progress-error",{detail:{methodName:t,errorMessage:i,errorCode:o,step:this.activeIndex},bubbles:!0})))};this.onSDKError=e=>{let t=e?.detail?.message||"SDK error occurred",i=e?.detail?.code||"SDK_ERROR";console.log("ICPay Progress: SDK error event received:",e.detail),this.failed=!0,this.errorMessage=this.transformErrorMessage(t),this.showSuccess=!1,this.updateStepStatus(this.activeIndex,"error",t),this.stopAutomaticProgression(),this.open=!0,this.dispatchEvent(new CustomEvent("icpay-progress-sdk-error",{detail:{errorMessage:t,errorCode:i,step:this.activeIndex},bubbles:!0}))};this.onWalletConnected=e=>{let t=e?.detail?.walletType||"unknown";console.log("ICPay Progress: Wallet connected event received:",e.detail),this.completeByKey("wallet"),this.setLoadingByKey("init"),this.dispatchEvent(new CustomEvent("icpay-progress-wallet-connected",{detail:{walletType:t,step:this.activeIndex},bubbles:!0}))};this.onWalletDisconnected=e=>{let t=e?.detail?.walletType||"unknown";console.log("ICPay Progress: Wallet disconnected event received:",e.detail),this.dispatchEvent(new CustomEvent("icpay-progress-wallet-disconnected",{detail:{walletType:t,step:this.activeIndex},bubbles:!0}))};this.onBalanceCheck=e=>{let t=e?.detail?.hasBalance||!1,i=e?.detail?.balance||0;console.log("ICPay Progress: Balance check event received:",e.detail),t||(this.failed=!0,this.errorMessage="Insufficient balance for transaction",this.updateStepStatus(this.activeIndex,"error","Insufficient balance for transaction"),this.stopAutomaticProgression(),this.dispatchEvent(new CustomEvent("icpay-progress-insufficient-balance",{detail:{balance:i,required:this.currentAmount||this.amount,step:this.activeIndex},bubbles:!0})))};this.onLedgerVerified=e=>{let t=e?.detail?.ledgerId||e?.detail?.canisterId,i=e?.detail?.symbol||"unknown";console.log("ICPay Progress: Ledger verified event received:",e.detail),i&&i!=="unknown"&&(this.currentLedgerSymbol=i,this.ledgerSymbol=i),this.dispatchEvent(new CustomEvent("icpay-progress-ledger-verified",{detail:{ledgerId:t,symbol:i,step:this.activeIndex},bubbles:!0}))};this.onWidgetPayment=e=>{let t=e?.detail?.amount,i=e?.detail?.currency,o=e?.detail?.ledgerSymbol;if(console.log("ICPay Progress: Widget payment event received:",e.detail),t!==void 0&&(this.currentAmount=t,this.amount=t),i&&(this.currentCurrency=i,this.currency=i),o&&(this.currentLedgerSymbol=o,this.ledgerSymbol=o),!this.failed){for(let r=this.activeIndex;r<this.currentSteps.length;r++)this.updateStepStatus(r,"completed");this.activeIndex=this.currentSteps.length-1,this.completed=!0,this.showSuccess=!0,this.showConfetti=!0}this.dispatchEvent(new CustomEvent("icpay-progress-widget-payment",{detail:{amount:t,currency:i,ledgerSymbol:o,step:this.activeIndex},bubbles:!0}))};this.onWidgetError=e=>{let t=e?.detail?.message||"Widget error occurred",i=e?.detail?.code||"WIDGET_ERROR";console.log("ICPay Progress: Widget error event received:",e.detail),this.failed=!0,this.errorMessage=this.transformErrorMessage(t),this.showSuccess=!1,this.updateStepStatus(this.activeIndex,"error",t),this.stopAutomaticProgression(),this.open=!0,this.dispatchEvent(new CustomEvent("icpay-progress-widget-error",{detail:{errorMessage:t,errorCode:i,step:this.activeIndex},bubbles:!0}))};this.onWidgetUnlock=e=>{let t=e?.detail?.amount,i=e?.detail?.currency;if(console.log("ICPay Progress: Widget unlock event received:",e.detail),!this.failed){for(let o=this.activeIndex;o<this.currentSteps.length;o++)this.updateStepStatus(o,"completed");this.activeIndex=this.currentSteps.length-1,this.completed=!0,this.showSuccess=!0,this.showConfetti=!0}this.dispatchEvent(new CustomEvent("icpay-progress-widget-unlock",{detail:{amount:t,currency:i,step:this.activeIndex},bubbles:!0}))};this.onWidgetTip=e=>{let t=e?.detail?.amount,i=e?.detail?.currency;if(console.log("ICPay Progress: Widget tip event received:",e.detail),!this.failed){for(let o=this.activeIndex;o<this.currentSteps.length;o++)this.updateStepStatus(o,"completed");this.activeIndex=this.currentSteps.length-1,this.completed=!0,this.showSuccess=!0,this.showConfetti=!0}this.dispatchEvent(new CustomEvent("icpay-progress-widget-tip",{detail:{amount:t,currency:i,step:this.activeIndex},bubbles:!0}))};this.onWidgetDonation=e=>{let t=e?.detail?.amount,i=e?.detail?.currency;if(console.log("ICPay Progress: Widget donation event received:",e.detail),!this.failed){for(let o=this.activeIndex;o<this.currentSteps.length;o++)this.updateStepStatus(o,"completed");this.activeIndex=this.currentSteps.length-1,this.completed=!0,this.showSuccess=!0,this.showConfetti=!0}this.dispatchEvent(new CustomEvent("icpay-progress-widget-donation",{detail:{amount:t,currency:i,step:this.activeIndex},bubbles:!0}))};this.onWidgetCoffee=e=>{let t=e?.detail?.amount,i=e?.detail?.currency;if(console.log("ICPay Progress: Widget coffee event received:",e.detail),!this.failed){for(let o=this.activeIndex;o<this.currentSteps.length;o++)this.updateStepStatus(o,"completed");this.activeIndex=this.currentSteps.length-1,this.completed=!0,this.showSuccess=!0,this.showConfetti=!0}this.dispatchEvent(new CustomEvent("icpay-progress-widget-coffee",{detail:{amount:t,currency:i,step:this.activeIndex},bubbles:!0}))}}connectedCallback(){super.connectedCallback();try{Q(this,this.theme)}catch{}this.currentSteps=[...this.steps],this.currentAmount=this.amount,this.currentCurrency=this.currency,this.currentLedgerSymbol=this.ledgerSymbol,this.attachSDKEventListeners()}disconnectedCallback(){super.disconnectedCallback(),this.detachSDKEventListeners(),this.stopAutomaticProgression()}updated(e){if(e.has("theme"))try{Q(this,this.theme)}catch{}}attachSDKEventListeners(){window.addEventListener("icpay-sdk-method-start",this.onMethodStart),window.addEventListener("icpay-sdk-method-success",this.onMethodSuccess),window.addEventListener("icpay-sdk-method-error",this.onMethodError),window.addEventListener("icpay-sdk-transaction-created",this.onTransactionCreated),window.addEventListener("icpay-sdk-transaction-updated",this.onTransactionUpdated),window.addEventListener("icpay-sdk-transaction-completed",this.onTransactionCompleted),window.addEventListener("icpay-sdk-transaction-failed",this.onTransactionFailed),window.addEventListener("icpay-sdk-error",this.onSDKError),window.addEventListener("icpay-sdk-wallet-connected",this.onWalletConnected),window.addEventListener("icpay-sdk-wallet-disconnected",this.onWalletDisconnected),window.addEventListener("icpay-sdk-balance-check",this.onBalanceCheck),window.addEventListener("icpay-sdk-ledger-verified",this.onLedgerVerified),window.addEventListener("icpay-pay",this.onWidgetPayment),window.addEventListener("icpay-error",this.onWidgetError),window.addEventListener("icpay-unlock",this.onWidgetUnlock),window.addEventListener("icpay-tip",this.onWidgetTip),window.addEventListener("icpay-donation",this.onWidgetDonation),window.addEventListener("icpay-coffee",this.onWidgetCoffee)}detachSDKEventListeners(){window.removeEventListener("icpay-sdk-method-start",this.onMethodStart),window.removeEventListener("icpay-sdk-method-success",this.onMethodSuccess),window.removeEventListener("icpay-sdk-method-error",this.onMethodError),window.removeEventListener("icpay-sdk-transaction-created",this.onTransactionCreated),window.removeEventListener("icpay-sdk-transaction-updated",this.onTransactionUpdated),window.removeEventListener("icpay-sdk-transaction-completed",this.onTransactionCompleted),window.removeEventListener("icpay-sdk-transaction-failed",this.onTransactionFailed),window.removeEventListener("icpay-sdk-error",this.onSDKError),window.removeEventListener("icpay-sdk-wallet-connected",this.onWalletConnected),window.removeEventListener("icpay-sdk-wallet-disconnected",this.onWalletDisconnected),window.removeEventListener("icpay-sdk-balance-check",this.onBalanceCheck),window.removeEventListener("icpay-sdk-ledger-verified",this.onLedgerVerified),window.removeEventListener("icpay-pay",this.onWidgetPayment),window.removeEventListener("icpay-error",this.onWidgetError),window.removeEventListener("icpay-unlock",this.onWidgetUnlock),window.removeEventListener("icpay-tip",this.onWidgetTip),window.removeEventListener("icpay-donation",this.onWidgetDonation),window.removeEventListener("icpay-coffee",this.onWidgetCoffee)}startAutomaticProgression(){this.progressionTimer&&clearInterval(this.progressionTimer),this.activeIndex=1,this.updateStepStatus(this.activeIndex,"loading"),console.log("ICPay Progress: Starting automatic progression from step:",this.activeIndex),this.progressionTimer=setInterval(()=>{if(this.failed||this.completed){this.stopAutomaticProgression();return}console.log("ICPay Progress: Processing step:",this.activeIndex),this.updateStepStatus(this.activeIndex,"completed"),this.activeIndex<this.currentSteps.length-1?(this.activeIndex++,this.updateStepStatus(this.activeIndex,"loading"),console.log("ICPay Progress: Auto-progressed to step:",this.activeIndex)):(this.stopAutomaticProgression(),console.log("ICPay Progress: All steps completed, waiting for transaction completion")),this.requestUpdate()},3e3)}stopAutomaticProgression(){this.progressionTimer&&(clearInterval(this.progressionTimer),this.progressionTimer=null)}updateStepStatus(e,t,i){if(e>=0&&e<this.currentSteps.length){let o=this.currentSteps[e],r=o.status;o.status=t,t==="completed"&&(o.timestamp=this.getCurrentTime()),t==="error"&&i&&(o.errorMessage=this.transformErrorMessage(i)),console.log(`ICPay Progress: Step ${e} (${o.label}) status changed from ${r} to ${t}`),this.requestUpdate()}}getCurrentTime(){return new Date().toLocaleTimeString("en-US",{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"})}progressPercent(){if(this.failed)return 0;if(this.showSuccess)return 100;let t=this.currentSteps.filter(i=>i.status==="completed").length/this.currentSteps.length*100;return Math.max(0,Math.min(100,t))}verticalPercent(){if(this.failed)return 0;if(this.showSuccess)return 100;let t=this.currentSteps.filter(i=>i.status==="completed").length/this.currentSteps.length*100;return Math.max(0,Math.min(100,t))}getStepIcon(e){switch(e.status){case"loading":return y`<div class="spinner"></div>`;case"completed":return"\u2713";case"error":return"\u2717";default:return"\u25CB"}}getStepIndexByKey(e){return this.currentSteps.findIndex(t=>t.key===e)}setLoadingByKey(e){let t=this.getStepIndexByKey(e);t>=0&&(this.activeIndex=t,this.updateStepStatus(t,"loading"))}completeByKey(e){let t=this.getStepIndexByKey(e);t>=0&&(this.updateStepStatus(t,"completed"),this.activeIndex=t)}transformErrorMessage(e){let t=String(e||"").toLowerCase();return t.includes("user rejected")||t.includes("user cancelled")||t.includes("user canceled")||t.includes("signature rejected")?"User have rejected the transfer":e}renderConfetti(){if(!this.showConfetti)return"";let e=Array.from({length:50},(i,o)=>o),t=["#0066FF","#ef4444","#10b981","#f59e0b","#8b5cf6"];return y`
61
60
  <div class="confetti">
62
61
  ${e.map(i=>y`
63
62
  <div
@@ -343,42 +342,122 @@ var Re=Object.defineProperty;var Te=Object.getOwnPropertyDescriptor;var s=(n,a,e
343
342
  opacity: 0;
344
343
  }
345
344
  }
346
- `,s([X({type:Boolean})],p.prototype,"open",2),s([X({type:Array})],p.prototype,"steps",2),s([X({type:Number})],p.prototype,"amount",2),s([X({type:String})],p.prototype,"currency",2),s([X({type:String})],p.prototype,"ledgerSymbol",2),s([T()],p.prototype,"activeIndex",2),s([T()],p.prototype,"completed",2),s([T()],p.prototype,"failed",2),s([T()],p.prototype,"errorMessage",2),s([T()],p.prototype,"showSuccess",2),s([T()],p.prototype,"showConfetti",2),s([T()],p.prototype,"currentSteps",2),s([T()],p.prototype,"currentAmount",2),s([T()],p.prototype,"currentCurrency",2),s([T()],p.prototype,"currentLedgerSymbol",2),s([X({type:Object})],p.prototype,"theme",2),p=s([_e("icpay-progress-bar")],p);import{LitElement as ze,html as ge,css as Ve}from"lit";import{customElement as He,property as he}from"lit/decorators.js";var P=class extends ze{constructor(){super(...arguments);this.options=[];this.value=null;this.defaultSymbol="ICP";this.mode="buttons"}connectedCallback(){super.connectedCallback();try{Q(this,this.theme)}catch{}}updated(e){if(e.has("theme"))try{Q(this,this.theme)}catch{}}get effectiveSymbol(){if(this.value)return this.value;let e=this.options?.[0]?.symbol;return this.defaultSymbol||e||"ICP"}onSelect(e){this.value=e,this.dispatchEvent(new CustomEvent("icpay-token-change",{detail:{symbol:e},bubbles:!0,composed:!0}))}render(){let e=this.options||[];if(this.mode==="none"||e.length<=1){let i=e.length===1?e[0].symbol:this.effectiveSymbol;return this.value!==i&&queueMicrotask(()=>this.onSelect(i)),ge``}if(this.mode==="dropdown"){let i=this.effectiveSymbol;return ge`
347
- <select @change=${r=>this.onSelect(r.target.value)}>
348
- ${e.map(r=>ge`<option value="${r.symbol}" ?selected=${i===r.symbol}>${r.label}<span class="icpay-token-selector-symbol"> (${r.symbol})</span></option>`)}
349
- </select>
350
- `}let t=this.effectiveSymbol;return ge`
351
- <div class="icpay-token-selector">
352
- <label class="label">Select Payment Method</label>
353
- <div class="crypto-grid">
354
- ${e.map(i=>ge`
355
- <div class="crypto-option ${t===i.symbol?"selected":""}" @click=${()=>this.onSelect(i.symbol)}>${i.label}<span class="icpay-token-selector-symbol"> (${i.symbol})</span></div>
356
- `)}
345
+ `,s([_({type:Boolean})],p.prototype,"open",2),s([_({type:Array})],p.prototype,"steps",2),s([_({type:Number})],p.prototype,"amount",2),s([_({type:String})],p.prototype,"currency",2),s([_({type:String})],p.prototype,"ledgerSymbol",2),s([$()],p.prototype,"activeIndex",2),s([$()],p.prototype,"completed",2),s([$()],p.prototype,"failed",2),s([$()],p.prototype,"errorMessage",2),s([$()],p.prototype,"showSuccess",2),s([$()],p.prototype,"showConfetti",2),s([$()],p.prototype,"currentSteps",2),s([$()],p.prototype,"currentAmount",2),s([$()],p.prototype,"currentCurrency",2),s([$()],p.prototype,"currentLedgerSymbol",2),s([_({type:Object})],p.prototype,"theme",2),p=s([Ve("icpay-progress-bar")],p);import{LitElement as Ge,html as Z,css as Ye}from"lit";import{customElement as Ze,property as H}from"lit/decorators.js";import{query as Te}from"lit/decorators.js";var C=class extends Ge{constructor(){super(...arguments);this.options=[];this.value=null;this.defaultSymbol="ICP";this.mode="buttons";this.open=!1;this.showLabel=!0;this.menuPos={left:0,top:0,width:0}}connectedCallback(){super.connectedCallback();try{Q(this,this.theme)}catch{}}updated(e){if(e.has("theme"))try{Q(this,this.theme)}catch{}}firstUpdated(){let e=i=>{if(!this.open)return;i.composedPath().includes(this)||this.closeDropdown()},t=i=>{i.key==="Escape"&&this.open&&this.closeDropdown()};this._onDocClick=e,this._onKey=t,window.addEventListener("click",e),window.addEventListener("keydown",t)}disconnectedCallback(){super.disconnectedCallback();let e=this._onDocClick,t=this._onKey;e&&window.removeEventListener("click",e),t&&window.removeEventListener("keydown",t)}get effectiveSymbol(){if(this.value)return this.value;let e=this.options?.[0]?.symbol;return this.defaultSymbol||e||"ICP"}getOptionBySymbol(e){return(this.options||[]).find(t=>t.symbol===e)}getLogoUrl(e){return`https://widget.icpay.org/ledger/${String(e||"").toLowerCase()}.svg`}onSelect(e){this.value=e,this.requestUpdate("value"),this.open=!1,this.dispatchEvent(new CustomEvent("icpay-token-change",{detail:{symbol:e},bubbles:!0,composed:!0}))}toggleDropdown(){this.open=!this.open}closeDropdown(){this.open=!1}render(){let e=this.options||[];if(this.mode==="none"||e.length<=1){let i=e.length===1?e[0].symbol:this.effectiveSymbol;return this.value!==i&&queueMicrotask(()=>this.onSelect(i)),Z``}if(this.mode==="dropdown"){let i=this.effectiveSymbol,o=this.getOptionBySymbol(i)||{symbol:i,label:i};return Z`
346
+ ${this.showLabel?Z`<label class="icpay-dropdown-label">Payment method</label>`:null}
347
+ <div class="dropdown-wrapper">
348
+ <div class="dropdown-trigger ${this.open?"open":""}" @click=${()=>this.toggleDropdown()}>
349
+ <div class="selected-option">
350
+ <img class="dropdown-selected-icon" src="${this.getLogoUrl(o.symbol)}" alt="${o.symbol}" />
351
+ <div class="crypto-info">
352
+ <div class="dropdown-crypto-name">${o.label}</div>
353
+ <div class="dropdown-crypto-symbol">${o.symbol}</div>
354
+ </div>
355
+ </div>
356
+ <svg class="dropdown-arrow" fill="none" viewBox="0 0 24 24" stroke="currentColor" aria-hidden="true">
357
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7" />
358
+ </svg>
359
+ </div>
360
+
361
+ <div class="dropdown-menu ${this.open?"open":""}">
362
+ ${e.map(r=>Z`
363
+ <div class="dropdown-option ${this.value===r.symbol||i===r.symbol?"selected":""}" @click=${()=>this.onSelect(r.symbol)}>
364
+ <img class="dropdown-selected-icon" src="${this.getLogoUrl(r.symbol)}" alt="${r.symbol}" />
365
+ <div class="crypto-info">
366
+ <div class="dropdown-crypto-name">${r.label}</div>
367
+ <div class="dropdown-crypto-symbol">${r.symbol}</div>
368
+ </div>
369
+ </div>
370
+ `)}
371
+ </div>
372
+ </div>
373
+ <div class="dropdown-backdrop ${this.open?"open":""}" @click=${()=>this.closeDropdown()}></div>
374
+ `}let t=this.effectiveSymbol;return Z`
375
+ <div class="icpay-token-selector" style="width:100%;box-sizing:border-box;">
376
+ ${this.showLabel?Z`<label class="label">Payment method</label>`:null}
377
+ <div class="crypto-grid">
378
+ ${e.map(i=>Z`
379
+ <div class="crypto-option ${t===i.symbol?"selected":""}" @click=${()=>this.onSelect(i.symbol)}>
380
+ <img class="crypto-icon" src="${this.getLogoUrl(i.symbol)}" alt="${i.symbol}" />
381
+ <div class="crypto-name">${i.label}</div>
382
+ <div class="crypto-symbol">${i.symbol}</div>
383
+ </div>
384
+ `)}
385
+ </div>
357
386
  </div>
358
- </div>
359
- `}};P.styles=Ve`
360
- :host { display: block; }
361
- .crypto-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0 16px; }
362
- .crypto-option { background: var(--icpay-surface-alt); border: 2px solid var(--icpay-border); border-radius: 12px; padding: 12px 8px; text-align: center; cursor: pointer; color: var(--icpay-text); font-weight: 600; font-size: 12px; }
363
- .crypto-option.selected { background: var(--icpay-primary); color: #111827; border-color: var(--icpay-primary); }
364
- select { background: var(--icpay-surface-alt); border: 1px solid var(--icpay-border); color: var(--icpay-text); border-radius: 8px; padding: 10px; font-weight: 600; }
365
- `,s([he({type:Array})],P.prototype,"options",2),s([he({type:String})],P.prototype,"value",2),s([he({type:String})],P.prototype,"defaultSymbol",2),s([he({type:String})],P.prototype,"mode",2),s([he({type:Object})],P.prototype,"theme",2),P=s([He("icpay-token-selector")],P);import{html as me}from"lit";function $(n){if(!n.visible)return null;let{wallets:a,onSelect:e,onClose:t,isConnecting:i}=n;return me`
387
+ `}};C.styles=Ye`
388
+ :host { display: block; width: 100%; box-sizing: border-box; }
389
+
390
+ /* Common */
391
+ .label,
392
+ .icpay-dropdown-label { font-size: 14px; font-weight: 600; color: var(--icpay-text, #fff); margin-bottom: 8px; display: block; }
393
+
394
+ /* Buttons grid (from crypto-payment-selector) */
395
+ .crypto-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; width: 100%; margin: 12px 0 16px; box-sizing: border-box; }
396
+ .crypto-option { background: var(--icpay-surface-alt, #2a3142); border: 1px solid var(--icpay-border, #3a4154); border-radius: 8px; padding: 8px 4px; cursor: pointer; transition: all 0.15s ease; position: relative; overflow: hidden; display: flex; flex-direction: column; align-items: center; gap: 4px; min-height: 60px; }
397
+ .crypto-option:active { transform: scale(0.95); }
398
+ .crypto-option.selected { background: #f7f7f7; border-color: #ffffff; }
399
+ .crypto-option.selected .crypto-name { color: #1a1f2e; }
400
+ .crypto-option.selected .crypto-symbol { color: #4a5568; }
401
+ .crypto-option.selected::after { content: "✓"; position: absolute; top: 4px; right: 4px; width: 16px; height: 16px; background-color: #22C55E; color: white; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: bold; }
402
+
403
+ /* Icon as external SVG image with constraints */
404
+ .crypto-icon { width: 24px; height: 24px; border-radius: 50%; object-fit: contain; background: transparent; flex-shrink: 0; }
405
+ .crypto-name { font-size: 11px; font-weight: 600; color: var(--icpay-text, #ffffff); text-align: center; line-height: 1.1; }
406
+ .crypto-symbol { font-size: 9px; color: var(--icpay-muted-text, #888); text-align: center; line-height: 1; }
407
+
408
+ /* Dropdown (from crypto-dropdown-selector) */
409
+ .dropdown-wrapper { position: relative; width: 100%; box-sizing: border-box; }
410
+ .dropdown-trigger { position: relative; width: 100%; box-sizing: border-box; background: var(--icpay-surface, #0a0a0a); border: 1px solid var(--icpay-border, #262626); border-radius: 12px; padding: 10px 40px 10px 16px; cursor: pointer; transition: all 0.2s ease; display: flex; align-items: center; gap: 12px; min-height: 44px; }
411
+ .dropdown-trigger:hover { border-color: #404040; background: #171717; }
412
+ .dropdown-trigger:active { transform: scale(0.99); }
413
+ .dropdown-trigger.open { border-color: #525252; background: #171717; border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
414
+ .selected-option { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
415
+ .dropdown-selected-icon { width: 32px; height: 32px; border-radius: 50%; object-fit: contain; flex-shrink: 0; }
416
+ .dropdown-crypto-name { font-size: 14px; font-weight: 600; color: var(--icpay-text, #ffffff); line-height: 1.2; }
417
+ .dropdown-crypto-symbol { font-size: 12px; color: var(--icpay-muted-text, #a3a3a3); line-height: 1.2; }
418
+ .dropdown-arrow { width: 20px; height: 20px; color: #a3a3a3; transition: transform 0.2s ease; position: absolute; right: 12px; top: 50%; transform: translateY(-50%); pointer-events: none; }
419
+ .dropdown-trigger.open .dropdown-arrow { transform: translateY(-50%) rotate(180deg); color: #ffffff; }
420
+ /* Render menu as absolute under wrapper to align within widget */
421
+ .dropdown-wrapper { position: relative; }
422
+ .dropdown-menu { position: absolute; left: 0; top: 100%; background: var(--icpay-surface, #0a0a0a); border: 1px solid var(--icpay-border, #262626); border-top: none; border-radius: 0 0 12px 12px; overflow: hidden; opacity: 0; visibility: hidden; transform: translateY(-10px); transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease; z-index: 1000; box-shadow: 0 8px 24px rgba(0,0,0,0.5); max-height: 280px; overflow-y: auto; width: 100%; box-sizing: border-box; }
423
+ .dropdown-menu.open { opacity: 1; visibility: visible; transform: translateY(0); }
424
+ .dropdown-option { display: flex; align-items: center; gap: 12px; padding: 12px 16px; cursor: pointer; transition: background 0.15s ease; border-bottom: 1px solid #171717; }
425
+ .dropdown-option:last-child { border-bottom: none; }
426
+ .dropdown-option:hover { background: #171717; }
427
+ .dropdown-option:active { background: #262626; }
428
+ .dropdown-option.selected { background: #171717; }
429
+ .dropdown-menu::-webkit-scrollbar { width: 4px; }
430
+ .dropdown-menu::-webkit-scrollbar-track { background: #171717; }
431
+ .dropdown-menu::-webkit-scrollbar-thumb { background: #404040; border-radius: 2px; }
432
+ .dropdown-menu::-webkit-scrollbar-thumb:hover { background: #525252; }
433
+ .dropdown-backdrop { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.2); opacity: 0; visibility: hidden; transition: all 0.2s ease; z-index: 500; }
434
+ .dropdown-backdrop.open { opacity: 1; visibility: visible; }
435
+
436
+ /* Small screens */
437
+ @media (max-width: 320px) {
438
+ .crypto-grid { gap: 4px; }
439
+ .crypto-option { padding: 6px 2px; min-height: 54px; }
440
+ .dropdown-trigger { padding: 10px 12px; min-height: 48px; }
441
+ .dropdown-option { padding: 10px 12px; }
442
+ .dropdown-selected-icon { width: 28px; height: 28px; }
443
+ }
444
+ `,s([H({type:Array})],C.prototype,"options",2),s([H({type:String})],C.prototype,"value",2),s([H({type:String})],C.prototype,"defaultSymbol",2),s([H({type:String})],C.prototype,"mode",2),s([H({type:Object})],C.prototype,"theme",2),s([H({type:Boolean})],C.prototype,"open",2),s([H({type:Boolean})],C.prototype,"showLabel",2),s([Te(".dropdown-trigger")],C.prototype,"triggerEl",2),s([Te(".dropdown-wrapper")],C.prototype,"wrapperEl",2),C=s([Ze("icpay-token-selector")],C);import{html as be}from"lit";var He="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAACXBIWXMAAAsTAAALEwEAmpwYAAAE9GlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgOS4xLWMwMDIgNzkuZGJhM2RhM2I1LCAyMDIzLzEyLzE1LTEwOjQyOjM3ICAgICAgICAiPiA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPiA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtbG5zOmRjPSJodHRwOi8vcHVybC5vcmcvZGMvZWxlbWVudHMvMS4xLyIgeG1sbnM6cGhvdG9zaG9wPSJodHRwOi8vbnMuYWRvYmUuY29tL3Bob3Rvc2hvcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RFdnQ9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZUV2ZW50IyIgeG1wOkNyZWF0b3JUb29sPSJBZG9iZSBQaG90b3Nob3AgMjUuNyAoTWFjaW50b3NoKSIgeG1wOkNyZWF0ZURhdGU9IjIwMjUtMDktMDRUMTc6MTk6NDErMDI6MDAiIHhtcDpNb2RpZnlEYXRlPSIyMDI1LTA5LTA0VDE3OjIzOjU5KzAyOjAwIiB4bXA6TWV0YWRhdGFEYXRlPSIyMDI1LTA5LTA0VDE3OjIzOjU5KzAyOjAwIiBkYzpmb3JtYXQ9ImltYWdlL3BuZyIgcGhvdG9zaG9wOkNvbG9yTW9kZT0iMyIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDo1YTMxZThhMi05MzVkLTRkY2YtOTk0Mi05NjgxZWE5MTQ0MDgiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6NWEzMWU4YTItOTM1ZC00ZGNmLTk5NDItOTY4MWVhOTE0NDA4IiB4bXBNTTpPcmlnaW5hbERvY3VtZW50SUQ9InhtcC5kaWQ6NWEzMWU4YTItOTM1ZC00ZGNmLTk5NDItOTY4MWVhOTE0NDA4Ij4gPHhtcE1NOkhpc3Rvcnk+IDxyZGY6U2VxPiA8cmRmOmxpIHN0RXZ0OmFjdGlvbj0iY3JlYXRlZCIgc3RFdnQ6aW5zdGFuY2VJRD0ieG1wLmlpZDo1YTMxZThhMi05MzVkLTRkY2YtOTk0Mi05NjgxZWE5MTQ0MDgiIHN0RXZ0OndoZW49IjIwMjUtMDktMDRUMTc6MTk6NDErMDI6MDAiIHN0RXZ0OnNvZnR3YXJlQWdlbnQ9IkFkb2JlIFBob3Rvc2hvcCAyNS43IChNYWNpbnRvc2gpIi8+IDwvcmRmOlNlcT4gPC94bXBNTTpIaXN0b3J5PiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/PqeyEHoAABSkSURBVHjajZt5jCRXfcc/r6q6+pru6Z2ZnT1nd32sj/Uaew2yI0M45ERgWdyHIggEkZAo/+QgTv5AICVEQgEUiFCUkMQiRjmJIBGYIEMIBBwfLAQfy9qLj/Xuzs7s7sz0zPR0z/RV9X75o6qr36uqXtHSaLqqXx3v937n9/d96q6H/nEJkZqIgNZE/wVEou/xn2g9PqdHv+nUsQiilYyvF0RU9Hve9aNj47lMepYxzni36FnaGGO8mzbe35iDce+2h8j+6CTjj8I6ltRJcyiSHp+92Bqfuiti3F0lh9YQxaR7pN5OUhemPgqFJM8FkJqD1u2RxBJBCPFA8yWTS1Hmb/HNVPxFZMJEk2faAlXpl0wvhBrfQVTqvpL3lImizhvVdsZqbq7vWBDjGY3H5d1PJp7Mrl8yD1HjyYnkT0OMZ1vnlaF+OVel1VQk5+4KJ2UTkQ1pMa5LT1wmyFhypC4TpJQzWaVigUxYVpVzbJlS6leVK/LMYnnJZGNVF0vaafWNVTzRGDHOGcMlb8VSiyNpbZk0PuNt8sdPnuUEGUbfPPNGphqKOQnJE4rkOymRqxih5P2zBqpEviO/I+ZPP4eNT/S6Y5kbv3siqQmNbMUMgZLVdrEWzzCj9EPTGirZAWItQs6glD2PxovhOGXSwkveooyPvUR/zRc1Lhpphejx7BMzyZu0pAUS/SnJew9J+6nMvRQ5ztlU6Yz92SZ71VAh4KB18tIixuSFsTPUZhRIBmMZv3Wc9oWSTELyVMhyjLYKyM8R3/J9a07OouyLJDEBSTtCDM8vhlaMVte4VWphBEGLjuJ5JoymTSjfZmWUahiqoXVWaBMjxiQ/IFkz9EQkx0uQsv9o5iKjHChWa4RBGLDZ7dLu9xgGAaI1vuuiRDhQm1a+4xDovKRFUoLIUwLB9zyW1tdpd3cIgxDCIeDgex7T5TK1YinJ8ORqTjBH4xSCh5Z0HjleebHygWTyrlL0hkNe3lxn2i9y8+w8R2fmOFhrMF+dYr5SZb27w+ce/R7bgwFFx7V8h4rCrVhJpWQkAMDSxjrvuP1V3Hv8drZ7XZqdDufWVnh5bYXTFy9w9vIyJb/EoZlZBoHOzl/ykqCxeXggsY2bntr+b/oGB8Vmr8tKp81H7nwtb7vxOK/cdzDXRP/m5COsdrYolqvZLBKU7cDE9toCWoTNjQ3e9cq7uPeW2zL339zZ5uFTT/G5h7/Oyed+yvUHDxPoIBMtJvoNAXXiS3+5BVJDlB1PzPQxCcyiBkHAYmuTv773Hbzv+B0AbPV7/GhpkfOb6zS723T6PV5eX+PR8y9RcguRgkosaKNyi5ysHjtcSVV7Wtju91hozHD3dUepFUs0yhX2TTe4ae8Bbj90BICdQZ83ffoTPHL6Ga7fd5BhOMxUtOMKVZvHbXXiwc+3gPp4xZUdQmScISqBnzVXuP8XXscnXvcmAq25/7++ztfOnKK53WEQBGitcVGUPI+FeiMpQ6MHY5e/cTSJzCvvRcF3HVa3tlhpbUIYgg5BORQ9nxv27OFT7/kA977iBFvdHY787odRSlErluz0PhEs0X3HJXPb3fvWN30UKGbiici44IhVaRgGhKHmb+97F/ViiY9+9z/5829/ncbUNPPVKWYrFebKVWbKFWp+cZxDWOHV8jVqXEjm1BsihFoouh4z1Sl2TdWYmarTqFSp+D4vXDjHv/7wUd76yjs5PDfPzmDAwycfp1GrGxFZsoVa4uMYOKMCiAQ80Ib6RJIbOa+N7g4n9uzjYL1BNxjyldNPcXj/AvVi0SilDW9s5QdkwIzM75bZmem57dQU4DkONxw6Qthu8cD/fAeAO45cC66LFp1fiFnPjSTvJGiJOeEMGhQdt3s9rp+ZA+DkxfOsdNrRSmvJlq6Jykn+REglXZICDMxM0rRl4/JhEEJliq1uF4B6uYLyCvb7SBbPMIETTxL9VPkJkXHFMAg4PD0DwPPNVfrBMFUVSmpCkiqpU2NIYw2SmyKTqk1MLSsUClxubQBweG439VKZIAzwvYJdTE0ozBwSHGCMw9kaoMeYIMJ8pQrARncng7mRtvXUcaaGsLTE8BeIVY1mkjXj2opfZHm9CcA1u/cwX6/TGwzsrM9cECNZEgFHtFaZScf1gQkyatE4AoemdyXvosPY1nRqdazvBsAp2bQ/Uwmmy4mrVopC0fO40mqhtUYpxTXzexKTmJxnjG/oZFQr8QPaEooSKLoep69c4lK7xVPLi0yXSlGIM4CRjLqbKzdCnOxlyVSOeSYjYq/c6BalQoHN7TZf+7+TLDZXWV5vUo3DYF6tZRdloG79q0+l8oDJPYISI0A0GlN0CnUGfXeUK3V6XVquFDsMo0VFCfapOsVQkDMP8iZgxOak3dJwopaDyUchKw9/xOCUwGA4JdYjvuHR6XRrlKkEQ2NB9KsGKz7U9RFS6EEqwp5QjdFB4KNr9LtVCkV6/j6MUt99xB7WpGiLCoNvn9OlnaG1sMFWrRaqJbbda6zg5MsJm3Dtw0nAeQhiGRoJk9g7AVVAseHS6QzqDIfVyhUCHE8JgFhOwMUEm25uIEIrgOQ5ThSIgNNfWeO09b+CD97ydIIYNqsD3b7mFB7/4AKuXL+N4DkWvSG26joviSmuDzZ0diq4bCSJlZt1BnwONXUwVSwTDgPNrqwC4jAQ3NpsgCPEcxaHZ3VQKRbSnk3vmOT/JAXQ8JsDRYsRklY7bo7o/1Oyq1VgDngsu48SB5eh1x/mDP7qfF8+dp4DHySceZXlxkR0dcs3MHB95973MVWsMwgAVa5YCHMfh1NIF/uJb32Cr26Xd6fChN/wyb731BMpxEK2TvkHBcen0e/zzo9/nmz85yexUPQWhZz1+1h9GApBE1VUaEzC1JwWPi1BxPc6vrtJmlcs7LTygL5rnvDb3TR/hzbctMAUsLOzls3/2GVY7Wzzwa7/FW248PhHkueemW3h28QJ/942vcuLWE3zhvR/iap83HDvOtb/zJJ1+l6pfTCrbCQBTJlHzRHQKPFQ5ArAnPjKJoutyqbmGGm5TCAJ0GOILrA2HfJPz7HN9vEIZzxVKpSJHCrMcP3Q4KmXRuIATg/guUBxZ//wMtLa464abAGjF4IUDiba4gI/i4sZ6VNcrJwXrS6a7NSqwbFhci7IQVnSO0CQXKHGKPrq5SXtxmZ4D0h8Aguu4rAYhG5UKyulT8hX9ks+CdqiVa2wDAUKIwgFchNAQwKXpEpTL3LIQCaufCEvhxHhcGAvg9PJF1jc3WNi9x1Bzu7MlFvAr4xaeCI5EnyTrM7vD43NYOcJIjVTBY9DcoHPhIm6ljOu6uK6HFmG71aK/sYFe2yRwHYKZaRqeTwnoAEOEIP6LvkefZeBitYC3/wDX7tmLxGMH8bhhck30WVxfg8Fw7KeMSD+eqJFOpuoOD60VSk1uNprqlKnQBBkGSLMVOan4rONE7rDX67Gzs4PvOXSrPkdre6kATYJk5VWyshpw+OFgg7NOyP69e6iVSrGw4igQm4Ebh2OAk8+fAc+1U26RTOkd4ZmSAWk9EaPzodKYQPa7iGULCkDv9CKgIvWJNMJFwpDy3Ay37b+FITAkAk10bAIKwY0n9FhrlY4OuOXAAeYau2jF5qLjiTuxIBooXux1ePzMaRq16SSzs3HMbFcryrl0MtZOhXX2e4TokJWsaCUiQsGTcG0D2e6iCl6up97Z3uHwkSPcfPNNrMXqPkyptELRAl7utREFJ37xbuZru9gisExl9OcD3336SS4sLVErldPVpFjmIJLhI4z+O8RwlJhsDzNBybBF4t+i88opFgiurDG8eAVVKeUKoDvoM1+fpuHXaBHEWjASQvS9iMPZsMu5/jYzXpET1x1FAwNCY9x4PMDTL70Ig0FswSacHwOullBIFtLob+BYHSGDypJbIGmd0gIRUUrpbp/g0irK9XI7sl3R7HV9Kii6aGvlRytbAb7fXuWlXof9hRLzyqOVaAuW0Fw8LgE/PfsifqUqYhVidtiWTLFlo99eVJ2NG3FKDNbLVfxB/JDIcAsuwdp6FAYdJ7ExYnstOg4narPxio4dWeT2hAIOG8ATnSYDHbLXL7PbK7HJMJ4wSexXwAyKh144xeNPPcnumRlFOszFXl/E5JTkOcg4DCb0GG1US0n1pTPw8pjQpAXROJUyw3NLDC8s4U5VLA3YDkMOFqvcWJ1mlWG86pEjHIW3Kh7P622e77YpKZcTtVlmKNIhNMKkxOPBAx758Y8YtrcoOG7KPJOVU6SKsHSnOHKCMSCSxv8kywCzzCPu7UTXOg5hZ5vBixdQJd9wMIqtYMBCqUqDEu3E/sVSaR/FN9eXWexvM18ocazWoIPOqH4kLJ9TQZcfnDxJbWaOMAFvbK+fMlUDRsPoScQ+YLTiYiLDZgjRY7RYJKq4MCg1aI0zVaV/5izBpTWcWtQJGoqm5LjcPbOXAKFv2H80IU0Vn0UGPNJaQWvNtZUah/w6awwILc8PfYS9KL76vW/zs1PPMDM9bTRPtU2vM1Re0t7fcIxOSj9yHOBYGwquy+rWFi+tXKbT7eI7bqIZquQzXGmy8/iTuI06bqXMih5wYm4fryrtoQV4lPAo4lHExadChXlc/m2wxtnhDtPlCvcuXE8dH42HSxGXEh4lFD5HqPD0oMOXv/IVanNz8UJE+cbyepPlS0sEYYjnOPFiZTve4+pYEieoJMO2kmwTTWB5q8k7T9zJ647exBd+8B1eWLnCdKkce03BadTZ+clpnOkpuOMYN1cbvGX2EOsM6DBMEhkXKOAhus9nv/ctvtxvMn3sKG9s7OOoqnGOHSROjpy4YKpS5NnmFf74859haWmJwwuHCGJU+vLKFX7vzW/n+KEjfOwfvsh2r0vRKyRtN3LMYVTTpCgy+c1EUVF/fqPd5lfvejWvv+EYP7u8zGNnnmV634Ek/CjPhYJH+zuPwTNnmJqq8/fyMBtBL8r0DPVzlUtv0OOFM2eYqtVwfvwczxRKPDEY0JcwwhYMp+Xjsrh2STYur6hDCwsEQQACvUGfEOFP3/tBpsplHvzvh/nfU0+zb2bOLobS3ADJociIwVizIp+OWtoAF9fXoxeKY37S4yPKtZVfwHEdWNvk/KVVehJG14pNvwl1iOu4zO/ZixOEdM4tshIGhFrH7XMSAFViGy/5PvPz8zHWGFWtvcGA/bO7qZaiJGyz3aHgFbLcxyRP0LYJiBGzyemcWIIIAtY6bQCqxWLUrLTwewNRLBcplooULSBF7Pw8fintKNxqhRpYkJfVM4ibqDp+5uhZ3X6fPQcOopSi2W6x1Fyl4hfHdq8lS2Ux7ukxgdkVcXfTQIjiQjPC6A7NzEEMUxktZUNuORMn3SjBijiS8tQyIYExhRj2uizMzUfdqqWLbLTb7K5PWx1uqyFj3TNNkTERnwyPUfAKHi+tXAbgziPXUSmWGAQBvutKlBWmU1GbZZLp+6UJGJDTPCW/5YbgKAXdblQMAevtLej3LRRacgASk5rjkMR0nenwjFpio/xgtlzlJ+fOst3vcXhuN7cvHOHi+ZfxHEeNCiRtFlB6XGOMu87aTqiSyepsAqPJ7TJFxb2iOxjAVovXHIswxkvr69DdiQSTbtdNQoWjCGY0J7IhIAkn1WKRs4vnefjU07zzVXfxmfe8n7ctLfL8mWehUgEnQoQqRZ8pv0TZ95OkycYVk7pdRtVo2j+MflZEVJn2zjY7vT5BbwdCDb0edHf4wPt/nd94430APPDwQ3hTtVQk1ymTNBYoRoRGBNUs91osTBglUK9P84f/8iD3HDvO3Udv5MXPfoFPP/TvbO5ss9Xr0my3WV5vcnblMoPhkEalQhA3VseZaJK+KttMJBu2UKxubjI/3eDG/QdZmN1NvVxhyvd59bFb+ZXX3wPAn/zTg/zwicfYe+1R0KHNY2YS61VQ19z/2y0Vt8YmE8LHdlxwXZ5fWuS2I9fy+Q98mNfeeCwXA3jxyiXu+/QnuLK5QSPuKOdPFAu4UIJFp7l05RIfe+8H+dh73kfBy5bbWms+/qUH+OSXHmBmbjfFgj+uY5KcP+t74v9bHiJKJpENcxjpw0A4uv8gP108zy998uO8+867ec1Nx9hTb1AvV5ivT/OKQ0c4uGsW33UJQ52TiEgOGds+L7EgdBiwp7GLgudxeWOdly4vs95u09xq8cLSRf7jsR/w3KlnmD1wkJLvE6T7kZh9yExWqNQ1v/+bW4KqqZw9MDKB3AzgOg69QZ+l9SYMh+B5KOVQ9n0Ozc7R7nbpDQZMVyrjl8rVAnszhqRitYjQ6XbZXZ9mo91mvdWCYBj/hbi1Onsau6JVz+wp4irNWQGh7SXNxsT6ZQKf3Y7xQajxHJfDc/NRNRbfNNAhy80mnutEjcogmEjBterzHHrNqKQueQWW19YoeC67G43RTpqErxuGYfZameRTbL/mpR2dST9XBpZqUQjTdEyJUB6Je3aNSgSKhFpnJ5x2eumdKSnnJRIRonZVq9Z1koG4JUPJyeUqJFGJq6TCZDn+GZqyTKC8ZzcT5GeDpFPdFH9YJH/vQsqJKvIQayO8pmgxFpV+Uiqcx7qWiTz/VPqb20ojD7OzMkbbH+S0tJL5SnZ3W1b1ldW8SfIfUWmt8PJ3U03edpI3eUkR9sesNFFpLD5XGKRCotgNjjGbNE9Ykx1eiuessjympBZI1cKS5Var1DaVDLU+qxHKpt6TpeBmJptOishnjKWpdpIT52O/lak9UvVB5ANMODxNL5VJmxMkyyTJqQhVqjiy+ou5rPQcYWjJrSgzITTl8CY6Q0Mwng0ckCUWZpzHeDuHkEeoSGNxYxJm3n4klXaoabuGLN84XTdk/AbjvcMZaNx2vokARjHPJEgZG2JTiaFFK89xguMTgiiFZEtecnaoJfPTyf0tQCSzg9XWirR5ZNJua5ETREhqV98GKymgRDBcQop4kCE5q0z2lzoeV6PWaimbp5TDNjdJ2TobHrPZJjaFPnrvmofoZaA2yeEb+OBoSVX+Fptxu1zMt08mM3l/okz0A2RNJ8+UyKHnJvucRt7fYo7G52n/P922iheCzzh8AAAAAElFTkSuQmCC";function M(n){if(!n.visible)return null;let{wallets:a,onSelect:e,onClose:t,isConnecting:i}=n,o=a.map(r=>({...r,icon:r.icon??(r.id==="nfid"?He:null)}));return be`
366
445
  <div style="position:fixed;inset:0;display:flex;align-items:center;justify-content:center;background:rgba(0,0,0,0.5);z-index:10000">
367
446
  <div style="background:#1f2937;border-radius:12px;padding:24px;max-width:400px;width:90%;border:1px solid rgba(255,255,255,0.1);position:relative">
368
447
  <button @click=${t} style="position:absolute;top:16px;right:16px;width:32px;height:32px;display:flex;align-items:center;justify-content:center;color:#9ca3af;cursor:pointer;border:none;background:transparent;font-size:20px">✕</button>
369
448
  <h3 style="color:#fff;margin:0 48px 16px 0;font-size:18px;font-weight:600">Choose Wallet</h3>
370
449
  <div style="display:flex;flex-direction:column;gap:8px">
371
- ${a.map(r=>me`
450
+ ${o.map(r=>be`
372
451
  <button
373
452
  @click=${()=>e(r.id)}
374
453
  style="width:100%;padding:12px 16px;background:rgba(255,255,255,0.05);border:1px solid rgba(255,255,255,0.1);border-radius:8px;color:#fff;text-align:left;cursor:pointer;font-size:14px;opacity:${i?.5:1};display:flex;align-items:center;gap:12px">
375
- ${r.icon?me`
454
+ ${r.icon?be`
376
455
  <div style="width:48px;height:48px;display:flex;align-items:center;justify-content:center">
377
456
  <img src="${r.icon}" alt="${r.label} logo" style="width:40px;height:40px;object-fit:cover;border-radius:12px;border:1px solid rgba(156,163,175,0.3)" />
378
457
  </div>
379
- `:me`
458
+ `:be`
380
459
  <div style="width:48px;height:48px;background:linear-gradient(135deg,#3b82f6 0%,#8b5cf6 100%);border-radius:12px;display:flex;align-items:center;justify-content:center;font-size:12px;font-weight:bold;border:1px solid rgba(156,163,175,0.3)">
381
- ${(r.id||"?").charAt(0).toUpperCase()}
460
+ ${r.id?r.id==="nfid"?"NFID":r.id.charAt(0).toUpperCase():"?"}
382
461
  </div>
383
462
  `}
384
463
  <div><div style="font-weight:500">${r.label}</div></div>
@@ -387,12 +466,12 @@ var Re=Object.defineProperty;var Te=Object.getOwnPropertyDescriptor;var s=(n,a,e
387
466
  </div>
388
467
  </div>
389
468
  </div>
390
- `}var ve=typeof window<"u",J=null;function _(n,a,e){n&&(e!==void 0?console.log(`[ICPay Widget] ${a}`,e):console.log(`[ICPay Widget] ${a}`))}var m=class extends qe{constructor(){super(...arguments);this.selectedSymbol="ICP";this.unlocked=!1;this.succeeded=!1;this.processing=!1;this.availableLedgers=[];this.errorMessage=null;this.errorSeverity=null;this.errorAction=null;this.walletConnected=!1;this.pendingAction=null;this.showWalletModal=!1;this.pnp=null}async tryAutoConnectPNP(){try{if(!this.config||this.config?.useOwnWallet)return;let e=localStorage.getItem("icpay:pnp");if(!e)return;let t=JSON.parse(e);if(!t?.provider||!t?.principal)return;J||(J=(await import("@windoge98/plug-n-play")).PNP);let i=new J(this.config?.plugNPlay||{});this.walletConnected=!1,this.config={...this.config,connectedWallet:{owner:t.principal,principal:t.principal,connected:!1}}}catch{}}get cryptoOptions(){return this.config.cryptoOptions?this.config.cryptoOptions:this.availableLedgers}connectedCallback(){super.connectedCallback(),ve&&(_(this.config?.debug||!1,"Premium content connected",{config:this.config}),this.tryAutoConnectPNP(),this.config?.cryptoOptions&&this.config.cryptoOptions.length>0||this.loadVerifiedLedgers())}updated(e){if(e.has("config")&&this.pendingAction&&this.config?.actorProvider){let t=this.pendingAction;this.pendingAction=null;try{window.dispatchEvent(new CustomEvent("icpay-sdk-wallet-connected",{detail:{walletType:"external"}}))}catch{}setTimeout(()=>{t==="pay"&&this.onPay()},0)}}async loadVerifiedLedgers(){if(!(!ve||!this.config?.publishableKey))try{let t=await d(this.config).client.getVerifiedLedgers();this.availableLedgers=t.map(i=>({symbol:i.symbol,label:i.name,canisterId:i.canisterId})),this.selectedSymbol||(this.selectedSymbol=this.config?.defaultSymbol||this.availableLedgers[0]?.symbol||"ICP")}catch(e){console.warn("Failed to load verified ledgers:",e),this.availableLedgers=[{symbol:"ICP",label:"ICP",canisterId:"ryjl3-tyaaa-aaaaa-aaaba-cai"}],this.selectedSymbol||(this.selectedSymbol="ICP")}}async onPay(){if(ve&&!(this.processing||this.unlocked)){_(this.config?.debug||!1,"Premium content payment started",{priceUsd:this.config.priceUsd,selectedSymbol:this.selectedSymbol,useOwnWallet:this.config.useOwnWallet}),this.errorMessage=null,this.errorSeverity=null,this.errorAction=null;try{window.dispatchEvent(new CustomEvent("icpay-sdk-method-start",{detail:{name:"pay",type:"sendUsd",amount:this.config.priceUsd,currency:this.selectedSymbol}}))}catch{}this.processing=!0;try{if(this.config.useOwnWallet){if(!this.config.actorProvider){this.pendingAction="pay",this.dispatchEvent(new CustomEvent("icpay-connect-wallet",{bubbles:!0}));return}}else if(!this.walletConnected){_(this.config?.debug||!1,"Connecting to wallet via Plug N Play");try{J||(J=(await import("@windoge98/plug-n-play")).PNP),this.pnp=new J(this.config?.plugNPlay||{});let o=this.pnp.getEnabledWallets();if(_(this.config?.debug||!1,"Available wallets",o),!o?.length)throw new Error("No wallets available");this.pendingAction="pay",this.showWalletModal=!0;return}catch(o){_(this.config?.debug||!1,"Wallet connection error:",o),this.errorMessage=o instanceof Error?o.message:"Wallet connection failed",this.errorSeverity="error";return}}_(this.config?.debug||!1,"Creating SDK for payment");let e=d(this.config),i=this.cryptoOptions.find(o=>o.symbol===this.selectedSymbol).canisterId||await e.client.getLedgerCanisterIdBySymbol(this.selectedSymbol);_(this.config?.debug||!1,"Payment details",{priceUsd:this.config.priceUsd,selectedSymbol:this.selectedSymbol,canisterId:i});let r=await e.sendUsd(this.config.priceUsd,i,{context:"premium-content"});_(this.config?.debug||!1,"Payment completed",{resp:r}),this.unlocked=!0,this.succeeded=!0,this.config.onSuccess&&this.config.onSuccess({id:r.transactionId,status:r.status}),this.dispatchEvent(new CustomEvent("icpay-unlock",{detail:{amount:this.config.priceUsd,tx:r},bubbles:!0}))}catch(e){S(e,{onError:t=>{this.dispatchEvent(new CustomEvent("icpay-error",{detail:t,bubbles:!0})),W(t)&&(this.errorMessage=k(t),this.errorSeverity=L(t),this.errorAction=C(t))}})}finally{this.processing=!1}}}select(e){this.selectedSymbol=e}getWalletId(e){return e&&(e.id||e.provider||e.key)||""}getWalletLabel(e){return e&&(e.label||e.name||e.title||e.id)||"Wallet"}getWalletIcon(e){return e&&(e.icon||e.logo||e.image)||null}async connectWithWallet(e){if(this.pnp)try{if(!e)throw new Error("No wallet ID provided");let t=await this.pnp.connect(e);if(!!!(t&&(t.connected===!0||t.principal||t.owner||this.pnp?.account)))throw new Error("Wallet connection was rejected");this.walletConnected=!0;try{window.dispatchEvent(new CustomEvent("icpay-sdk-wallet-connected",{detail:{walletType:e}}))}catch{}this.config={...this.config,connectedWallet:t,actorProvider:(o,l)=>this.pnp.getActor({canisterId:o,idl:l,requiresSigning:!0,anon:!1})},this.showWalletModal=!1;let r=this.pendingAction;this.pendingAction=null,r==="pay"&&setTimeout(()=>this.onPay(),0)}catch(t){this.errorMessage=t instanceof Error?t.message:"Wallet connection failed",this.errorSeverity="error",this.showWalletModal=!1}}render(){return this.config?Z`
391
- <div class="card section">
392
- ${this.config?.progressBar?.enabled!==!1?Z`<icpay-progress-bar mode="${this.config?.progressBar?.mode||"modal"}"></icpay-progress-bar>`:null}
469
+ `}var ve=typeof window<"u",te=null;function F(n,a,e){n&&(e!==void 0?console.log(`[ICPay Widget] ${a}`,e):console.log(`[ICPay Widget] ${a}`))}var b=class extends Je{constructor(){super(...arguments);this.selectedSymbol="ICP";this.unlocked=!1;this.succeeded=!1;this.processing=!1;this.availableLedgers=[];this.errorMessage=null;this.errorSeverity=null;this.errorAction=null;this.walletConnected=!1;this.pendingAction=null;this.showWalletModal=!1;this.pnp=null}async tryAutoConnectPNP(){try{if(!this.config||this.config?.useOwnWallet)return;let e=localStorage.getItem("icpay:pnp");if(!e)return;let t=JSON.parse(e);if(!t?.provider||!t?.principal)return;te||(te=(await import("@windoge98/plug-n-play")).PNP);let i=new te(this.config?.plugNPlay||{});this.walletConnected=!1,this.config={...this.config,connectedWallet:{owner:t.principal,principal:t.principal,connected:!1}}}catch{}}get cryptoOptions(){return this.config.cryptoOptions?this.config.cryptoOptions:this.availableLedgers}connectedCallback(){super.connectedCallback(),ve&&(F(this.config?.debug||!1,"Premium content connected",{config:this.config}),this.tryAutoConnectPNP(),this.config?.cryptoOptions&&this.config.cryptoOptions.length>0||this.loadVerifiedLedgers())}updated(e){if(e.has("config")&&this.pendingAction&&this.config?.actorProvider){let t=this.pendingAction;this.pendingAction=null;try{window.dispatchEvent(new CustomEvent("icpay-sdk-wallet-connected",{detail:{walletType:"external"}}))}catch{}setTimeout(()=>{t==="pay"&&this.onPay()},0)}}async loadVerifiedLedgers(){if(!(!ve||!this.config?.publishableKey))try{let t=await d(this.config).client.getVerifiedLedgers();this.availableLedgers=t.map(i=>({symbol:i.symbol,label:i.name,canisterId:i.canisterId})),this.selectedSymbol||(this.selectedSymbol=this.config?.defaultSymbol||this.availableLedgers[0]?.symbol||"ICP")}catch(e){console.warn("Failed to load verified ledgers:",e),this.availableLedgers=[{symbol:"ICP",label:"ICP",canisterId:"ryjl3-tyaaa-aaaaa-aaaba-cai"}],this.selectedSymbol||(this.selectedSymbol="ICP")}}async onPay(){if(ve&&!(this.processing||this.unlocked)){F(this.config?.debug||!1,"Premium content payment started",{priceUsd:this.config.priceUsd,selectedSymbol:this.selectedSymbol,useOwnWallet:this.config.useOwnWallet}),this.errorMessage=null,this.errorSeverity=null,this.errorAction=null;try{window.dispatchEvent(new CustomEvent("icpay-sdk-method-start",{detail:{name:"pay",type:"sendUsd",amount:this.config.priceUsd,currency:this.selectedSymbol}}))}catch{}this.processing=!0;try{if(this.config.useOwnWallet){if(!this.config.actorProvider){this.pendingAction="pay",this.dispatchEvent(new CustomEvent("icpay-connect-wallet",{bubbles:!0}));return}}else if(!this.walletConnected){F(this.config?.debug||!1,"Connecting to wallet via Plug N Play");try{te||(te=(await import("@windoge98/plug-n-play")).PNP),this.pnp=new te(this.config?.plugNPlay||{});let r=this.pnp.getEnabledWallets();if(F(this.config?.debug||!1,"Available wallets",r),!r?.length)throw new Error("No wallets available");this.pendingAction="pay",this.showWalletModal=!0;return}catch(r){F(this.config?.debug||!1,"Wallet connection error:",r),this.errorMessage=r instanceof Error?r.message:"Wallet connection failed",this.errorSeverity="error";return}}F(this.config?.debug||!1,"Creating SDK for payment");let e=d(this.config),i=this.cryptoOptions.find(r=>r.symbol===this.selectedSymbol).canisterId||await e.client.getLedgerCanisterIdBySymbol(this.selectedSymbol);F(this.config?.debug||!1,"Payment details",{priceUsd:this.config.priceUsd,selectedSymbol:this.selectedSymbol,canisterId:i});let o=await e.sendUsd(this.config.priceUsd,i,{context:"premium-content"});F(this.config?.debug||!1,"Payment completed",{resp:o}),this.unlocked=!0,this.succeeded=!0,this.config.onSuccess&&this.config.onSuccess({id:o.transactionId,status:o.status}),this.dispatchEvent(new CustomEvent("icpay-unlock",{detail:{amount:this.config.priceUsd,tx:o},bubbles:!0}))}catch(e){S(e,{onError:t=>{this.dispatchEvent(new CustomEvent("icpay-error",{detail:t,bubbles:!0})),W(t)&&(this.errorMessage=k(t),this.errorSeverity=A(t),this.errorAction=L(t))}})}finally{this.processing=!1}}}select(e){this.selectedSymbol=e}getWalletId(e){return e&&(e.id||e.provider||e.key)||""}getWalletLabel(e){return e&&(e.label||e.name||e.title||e.id)||"Wallet"}getWalletIcon(e){return e&&(e.icon||e.logo||e.image)||null}async connectWithWallet(e){if(this.pnp)try{if(!e)throw new Error("No wallet ID provided");let t=await this.pnp.connect(e);if(!!!(t&&(t.connected===!0||t.principal||t.owner||this.pnp?.account)))throw new Error("Wallet connection was rejected");this.walletConnected=!0;try{window.dispatchEvent(new CustomEvent("icpay-sdk-wallet-connected",{detail:{walletType:e}}))}catch{}this.config={...this.config,connectedWallet:t,actorProvider:(r,l)=>this.pnp.getActor({canisterId:r,idl:l,requiresSigning:!0,anon:!1})},this.showWalletModal=!1;let o=this.pendingAction;this.pendingAction=null,o==="pay"&&setTimeout(()=>this.onPay(),0)}catch(t){this.errorMessage=t instanceof Error?t.message:"Wallet connection failed",this.errorSeverity="error",this.showWalletModal=!1}}render(){return this.config?ee`
470
+ <div class="icpay-card icpay-section">
471
+ ${this.config?.progressBar?.enabled!==!1?ee`<icpay-progress-bar mode="${this.config?.progressBar?.mode||"modal"}"></icpay-progress-bar>`:null}
393
472
  <div class="image-container">
394
473
  <div class="locked-image ${this.unlocked?"unlocked":""}" style="background-image:url('${this.config.imageUrl||""}')"></div>
395
- ${this.unlocked?null:Z`<div class="lock-overlay">🔒</div>`}
474
+ ${this.unlocked?null:ee`<div class="lock-overlay">🔒</div>`}
396
475
  </div>
397
476
 
398
477
  <div class="pricing">
@@ -414,19 +493,19 @@ var Re=Object.defineProperty;var Te=Object.getOwnPropertyDescriptor;var s=(n,a,e
414
493
  ${this.unlocked?"Unlocked":this.processing?"Processing\u2026":(this.config?.buttonLabel||"Pay ${amount} with {symbol}").replace("{amount}",`${Number(this.config?.priceUsd??0).toFixed(2)}`).replace("{symbol}",this.selectedSymbol)}
415
494
  </button>
416
495
 
417
- ${this.errorMessage?Z`
496
+ ${this.errorMessage?ee`
418
497
  <div class="error-message ${this.errorSeverity}" style="margin-top: 12px; padding: 8px 12px; border-radius: 6px; font-size: 14px; text-align: center;">
419
498
  ${this.errorMessage}
420
- ${this.errorAction?Z`
499
+ ${this.errorAction?ee`
421
500
  <button style="margin-left: 8px; padding: 4px 8px; background: transparent; border: 1px solid currentColor; border-radius: 4px; font-size: 12px; cursor: pointer;">
422
501
  ${this.errorAction}
423
502
  </button>
424
503
  `:""}
425
504
  </div>
426
505
  `:""}
427
- ${(()=>{let t=(this.pnp?.getEnabledWallets?.()||[]).map(i=>({id:this.getWalletId(i),label:this.getWalletLabel(i),icon:this.getWalletIcon(i)}));return $({visible:!!(this.showWalletModal&&this.pnp),wallets:t,isConnecting:!1,onSelect:i=>this.connectWithWallet(i),onClose:()=>{this.showWalletModal=!1}})})()}
506
+ ${(()=>{let t=(this.pnp?.getEnabledWallets?.()||[]).map(i=>({id:this.getWalletId(i),label:this.getWalletLabel(i),icon:this.getWalletIcon(i)}));return M({visible:!!(this.showWalletModal&&this.pnp),wallets:t,isConnecting:!1,onSelect:i=>this.connectWithWallet(i),onClose:()=>{this.showWalletModal=!1}})})()}
428
507
  </div>
429
- `:Z`<div class="card section">Loading...</div>`}};m.styles=[E,Ge`
508
+ `:ee`<div class="icpay-card icpay-section">Loading...</div>`}};b.styles=[E,Xe`
430
509
  .image-container {
431
510
  position: relative;
432
511
  border-radius: 16px;
@@ -477,17 +556,17 @@ var Re=Object.defineProperty;var Te=Object.getOwnPropertyDescriptor;var s=(n,a,e
477
556
  border-color: rgba(239, 68, 68, 0.3);
478
557
  color: #ef4444;
479
558
  }
480
- `],s([Qe({type:Object})],m.prototype,"config",2),s([U()],m.prototype,"selectedSymbol",2),s([U()],m.prototype,"unlocked",2),s([U()],m.prototype,"succeeded",2),s([U()],m.prototype,"processing",2),s([U()],m.prototype,"availableLedgers",2),s([U()],m.prototype,"errorMessage",2),s([U()],m.prototype,"errorSeverity",2),s([U()],m.prototype,"errorAction",2),s([U()],m.prototype,"walletConnected",2),s([U()],m.prototype,"pendingAction",2),s([U()],m.prototype,"showWalletModal",2),m=s([Ye("icpay-premium-content")],m);import{LitElement as Xe,html as q,css as Ze}from"lit";import{customElement as Je,property as et,state as M}from"lit/decorators.js";var we=typeof window<"u",te=null;function j(n,a,e){n&&(e!==void 0?console.log(`[ICPay Widget] ${a}`,e):console.log(`[ICPay Widget] ${a}`))}var h=class extends Xe{constructor(){super(...arguments);this.selectedAmount=1;this.selectedSymbol="ICP";this.total=0;this.processing=!1;this.succeeded=!1;this.availableLedgers=[];this.errorMessage=null;this.errorSeverity=null;this.errorAction=null;this.walletConnected=!1;this.pendingAction=null;this.showWalletModal=!1;this.pnp=null}async tryAutoConnectPNP(){try{if(!this.config||this.config?.useOwnWallet)return;let e=localStorage.getItem("icpay:pnp");if(!e)return;let t=JSON.parse(e);if(!t?.provider||!t?.principal)return;te||(te=(await import("@windoge98/plug-n-play")).PNP);let i=new te(this.config?.plugNPlay||{});this.walletConnected=!1,this.config={...this.config,connectedWallet:{owner:t.principal,principal:t.principal,connected:!1}}}catch{}}get amounts(){return this.config?.amountsUsd||[1,5,10]}get cryptoOptions(){return this.config.cryptoOptions?this.config.cryptoOptions:this.availableLedgers}connectedCallback(){super.connectedCallback(),we&&(j(this.config?.debug||!1,"Tip jar connected",{config:this.config}),this.config&&this.config.defaultAmountUsd&&(this.selectedAmount=this.config.defaultAmountUsd),this.tryAutoConnectPNP(),this.config?.cryptoOptions&&this.config.cryptoOptions.length>0||this.loadVerifiedLedgers(),this.config?.defaultSymbol&&(this.selectedSymbol=this.config.defaultSymbol))}updated(e){if(e.has("config")&&this.pendingAction&&this.config?.actorProvider){let t=this.pendingAction;this.pendingAction=null;try{window.dispatchEvent(new CustomEvent("icpay-sdk-wallet-connected",{detail:{walletType:"external"}}))}catch{}setTimeout(()=>{t==="tip"&&this.tip()},0)}}async loadVerifiedLedgers(){if(!(!we||!this.config?.publishableKey))try{let t=await d(this.config).client.getVerifiedLedgers();this.availableLedgers=t.map(i=>({symbol:i.symbol,label:i.name,canisterId:i.canisterId})),this.config?.cryptoOptions&&this.config.cryptoOptions.length===1&&(this.selectedSymbol=this.config.cryptoOptions[0].symbol),!this.selectedSymbol&&this.availableLedgers.length>0&&(this.selectedSymbol=this.config?.defaultSymbol||this.availableLedgers[0].symbol)}catch(e){console.warn("Failed to load verified ledgers:",e),this.availableLedgers=[{symbol:"ICP",label:"ICP",canisterId:"ryjl3-tyaaa-aaaaa-aaaba-cai"}],this.selectedSymbol||(this.selectedSymbol="ICP")}}selectAmount(e){this.selectedAmount=e}selectSymbol(e){this.selectedSymbol=e}get fillPercentage(){return Math.min(this.total/50*100,100)}async tip(){if(we&&(j(this.config?.debug||!1,"Tip button clicked!",{config:this.config,processing:this.processing}),!this.processing)){this.errorMessage=null,this.errorSeverity=null,this.errorAction=null;try{window.dispatchEvent(new CustomEvent("icpay-sdk-method-start",{detail:{name:"tip",type:"sendUsd",amount:this.selectedAmount,currency:this.selectedSymbol}}))}catch{}this.processing=!0;try{if(this.config.useOwnWallet){if(!this.config.actorProvider){this.pendingAction="tip",this.dispatchEvent(new CustomEvent("icpay-connect-wallet",{bubbles:!0}));return}}else if(!this.walletConnected){j(this.config?.debug||!1,"Connecting to wallet via Plug N Play");try{te||(te=(await import("@windoge98/plug-n-play")).PNP),this.pnp=new te(this.config?.plugNPlay||{});let o=this.pnp.getEnabledWallets();if(j(this.config?.debug||!1,"Available wallets",o),!o?.length)throw new Error("No wallets available");this.pendingAction="tip",this.showWalletModal=!0;return}catch(o){j(this.config?.debug||!1,"Wallet connection error:",o),this.errorMessage=o instanceof Error?o.message:"Wallet connection failed",this.errorSeverity="error";return}}j(this.config?.debug||!1,"Creating SDK for payment");let e=d(this.config),i=this.cryptoOptions.find(o=>o.symbol===this.selectedSymbol).canisterId||await e.client.getLedgerCanisterIdBySymbol(this.selectedSymbol);j(this.config?.debug||!1,"Tip payment details",{amount:this.selectedAmount,selectedSymbol:this.selectedSymbol,canisterId:i});let r=await e.sendUsd(this.selectedAmount,i,{context:"tip-jar"});j(this.config?.debug||!1,"Tip payment completed",{resp:r}),this.total+=this.selectedAmount,this.succeeded=!0,this.config.onSuccess&&this.config.onSuccess({id:r.transactionId,status:r.status,total:this.total}),this.dispatchEvent(new CustomEvent("icpay-tip",{detail:{amount:this.selectedAmount,tx:r},bubbles:!0}))}catch(e){S(e,{onError:t=>{this.dispatchEvent(new CustomEvent("icpay-error",{detail:t,bubbles:!0})),W(t)&&(this.errorMessage=k(t),this.errorSeverity=L(t),this.errorAction=C(t))}})}finally{this.processing=!1}}}getWalletId(e){return e&&(e.id||e.provider||e.key)||""}getWalletLabel(e){return e&&(e.label||e.name||e.title||e.id)||"Wallet"}getWalletIcon(e){return e&&(e.icon||e.logo||e.image)||null}async connectWithWallet(e){if(this.pnp)try{if(!e)throw new Error("No wallet ID provided");let t=await this.pnp.connect(e);if(!!!(t&&(t.connected===!0||t.principal||t.owner||this.pnp?.account)))throw new Error("Wallet connection was rejected");this.walletConnected=!0;try{window.dispatchEvent(new CustomEvent("icpay-sdk-wallet-connected",{detail:{walletType:e}}))}catch{}this.config={...this.config,connectedWallet:t,actorProvider:(o,l)=>this.pnp.getActor({canisterId:o,idl:l,requiresSigning:!0,anon:!1})},this.showWalletModal=!1;let r=this.pendingAction;this.pendingAction=null,r==="tip"&&setTimeout(()=>this.tip(),0)}catch(t){this.errorMessage=t instanceof Error?t.message:"Wallet connection failed",this.errorSeverity="error",this.showWalletModal=!1}}render(){if(!this.config)return q`<div class="card section">Loading...</div>`;let t=(this.cryptoOptions?.length||0)>1,i=this.config?.showLedgerDropdown,r=i==="dropdown"?"dropdown":i==="none"?"none":"buttons",o=r!=="none"&&(t||r==="dropdown"),l=r==="dropdown"?"dropdown":t?"buttons":"none";return q`
481
- <div class="card section" style="text-align:center;">
482
- ${this.config?.progressBar?.enabled!==!1?q`<icpay-progress-bar></icpay-progress-bar>`:null}
559
+ `],s([Qe({type:Object})],b.prototype,"config",2),s([U()],b.prototype,"selectedSymbol",2),s([U()],b.prototype,"unlocked",2),s([U()],b.prototype,"succeeded",2),s([U()],b.prototype,"processing",2),s([U()],b.prototype,"availableLedgers",2),s([U()],b.prototype,"errorMessage",2),s([U()],b.prototype,"errorSeverity",2),s([U()],b.prototype,"errorAction",2),s([U()],b.prototype,"walletConnected",2),s([U()],b.prototype,"pendingAction",2),s([U()],b.prototype,"showWalletModal",2),b=s([qe("icpay-premium-content")],b);import{LitElement as _e,html as J,css as et}from"lit";import{customElement as tt,property as it,state as I}from"lit/decorators.js";var we=typeof window<"u",se=null;function V(n,a,e){n&&(e!==void 0?console.log(`[ICPay Widget] ${a}`,e):console.log(`[ICPay Widget] ${a}`))}var h=class extends _e{constructor(){super(...arguments);this.selectedAmount=1;this.selectedSymbol="ICP";this.total=0;this.processing=!1;this.succeeded=!1;this.availableLedgers=[];this.errorMessage=null;this.errorSeverity=null;this.errorAction=null;this.walletConnected=!1;this.pendingAction=null;this.showWalletModal=!1;this.pnp=null}async tryAutoConnectPNP(){try{if(!this.config||this.config?.useOwnWallet)return;let e=localStorage.getItem("icpay:pnp");if(!e)return;let t=JSON.parse(e);if(!t?.provider||!t?.principal)return;se||(se=(await import("@windoge98/plug-n-play")).PNP);let i=new se(this.config?.plugNPlay||{});this.walletConnected=!1,this.config={...this.config,connectedWallet:{owner:t.principal,principal:t.principal,connected:!1}}}catch{}}get amounts(){return this.config?.amountsUsd||[1,5,10]}get cryptoOptions(){return this.config.cryptoOptions?this.config.cryptoOptions:this.availableLedgers}connectedCallback(){super.connectedCallback(),we&&(V(this.config?.debug||!1,"Tip jar connected",{config:this.config}),this.config&&this.config.defaultAmountUsd&&(this.selectedAmount=this.config.defaultAmountUsd),this.tryAutoConnectPNP(),this.config?.cryptoOptions&&this.config.cryptoOptions.length>0||this.loadVerifiedLedgers(),this.config?.defaultSymbol&&(this.selectedSymbol=this.config.defaultSymbol))}updated(e){if(e.has("config")&&this.pendingAction&&this.config?.actorProvider){let t=this.pendingAction;this.pendingAction=null;try{window.dispatchEvent(new CustomEvent("icpay-sdk-wallet-connected",{detail:{walletType:"external"}}))}catch{}setTimeout(()=>{t==="tip"&&this.tip()},0)}}async loadVerifiedLedgers(){if(!(!we||!this.config?.publishableKey))try{let t=await d(this.config).client.getVerifiedLedgers();this.availableLedgers=t.map(i=>({symbol:i.symbol,label:i.name,canisterId:i.canisterId})),this.config?.cryptoOptions&&this.config.cryptoOptions.length===1&&(this.selectedSymbol=this.config.cryptoOptions[0].symbol),!this.selectedSymbol&&this.availableLedgers.length>0&&(this.selectedSymbol=this.config?.defaultSymbol||this.availableLedgers[0].symbol)}catch(e){console.warn("Failed to load verified ledgers:",e),this.availableLedgers=[{symbol:"ICP",label:"ICP",canisterId:"ryjl3-tyaaa-aaaaa-aaaba-cai"}],this.selectedSymbol||(this.selectedSymbol="ICP")}}selectAmount(e){this.selectedAmount=e}selectSymbol(e){this.selectedSymbol=e}get fillPercentage(){return Math.min(this.total/50*100,100)}async tip(){if(we&&(V(this.config?.debug||!1,"Tip button clicked!",{config:this.config,processing:this.processing}),!this.processing)){this.errorMessage=null,this.errorSeverity=null,this.errorAction=null;try{window.dispatchEvent(new CustomEvent("icpay-sdk-method-start",{detail:{name:"tip",type:"sendUsd",amount:this.selectedAmount,currency:this.selectedSymbol}}))}catch{}this.processing=!0;try{if(this.config.useOwnWallet){if(!this.config.actorProvider){this.pendingAction="tip",this.dispatchEvent(new CustomEvent("icpay-connect-wallet",{bubbles:!0}));return}}else if(!this.walletConnected){V(this.config?.debug||!1,"Connecting to wallet via Plug N Play");try{se||(se=(await import("@windoge98/plug-n-play")).PNP),this.pnp=new se(this.config?.plugNPlay||{});let r=this.pnp.getEnabledWallets();if(V(this.config?.debug||!1,"Available wallets",r),!r?.length)throw new Error("No wallets available");this.pendingAction="tip",this.showWalletModal=!0;return}catch(r){V(this.config?.debug||!1,"Wallet connection error:",r),this.errorMessage=r instanceof Error?r.message:"Wallet connection failed",this.errorSeverity="error";return}}V(this.config?.debug||!1,"Creating SDK for payment");let e=d(this.config),i=this.cryptoOptions.find(r=>r.symbol===this.selectedSymbol).canisterId||await e.client.getLedgerCanisterIdBySymbol(this.selectedSymbol);V(this.config?.debug||!1,"Tip payment details",{amount:this.selectedAmount,selectedSymbol:this.selectedSymbol,canisterId:i});let o=await e.sendUsd(this.selectedAmount,i,{context:"tip-jar"});V(this.config?.debug||!1,"Tip payment completed",{resp:o}),this.total+=this.selectedAmount,this.succeeded=!0,this.config.onSuccess&&this.config.onSuccess({id:o.transactionId,status:o.status,total:this.total}),this.dispatchEvent(new CustomEvent("icpay-tip",{detail:{amount:this.selectedAmount,tx:o},bubbles:!0}))}catch(e){S(e,{onError:t=>{this.dispatchEvent(new CustomEvent("icpay-error",{detail:t,bubbles:!0})),W(t)&&(this.errorMessage=k(t),this.errorSeverity=A(t),this.errorAction=L(t))}})}finally{this.processing=!1}}}getWalletId(e){return e&&(e.id||e.provider||e.key)||""}getWalletLabel(e){return e&&(e.label||e.name||e.title||e.id)||"Wallet"}getWalletIcon(e){return e&&(e.icon||e.logo||e.image)||null}async connectWithWallet(e){if(this.pnp)try{if(!e)throw new Error("No wallet ID provided");let t=await this.pnp.connect(e);if(!!!(t&&(t.connected===!0||t.principal||t.owner||this.pnp?.account)))throw new Error("Wallet connection was rejected");this.walletConnected=!0;try{window.dispatchEvent(new CustomEvent("icpay-sdk-wallet-connected",{detail:{walletType:e}}))}catch{}this.config={...this.config,connectedWallet:t,actorProvider:(r,l)=>this.pnp.getActor({canisterId:r,idl:l,requiresSigning:!0,anon:!1})},this.showWalletModal=!1;let o=this.pendingAction;this.pendingAction=null,o==="tip"&&setTimeout(()=>this.tip(),0)}catch(t){this.errorMessage=t instanceof Error?t.message:"Wallet connection failed",this.errorSeverity="error",this.showWalletModal=!1}}render(){if(!this.config)return J`<div class="icpay-card icpay-section">Loading...</div>`;let t=(this.cryptoOptions?.length||0)>1,i=this.config?.showLedgerDropdown,o=i==="dropdown"?"dropdown":i==="none"?"none":"buttons",r=o!=="none"&&(t||o==="dropdown"),l=o==="dropdown"?"dropdown":t?"buttons":"none";return J`
560
+ <div class="icpay-card icpay-section" style="text-align:center;">
561
+ ${this.config?.progressBar?.enabled!==!1?J`<icpay-progress-bar></icpay-progress-bar>`:null}
483
562
  <div class="jar"><div class="fill" style="height:${this.fillPercentage}%"></div></div>
484
563
  <div class="label">Total Tips: $${this.total}</div>
485
564
 
486
565
  <div class="amounts">
487
- ${this.amounts.map(c=>q`<div class="chip ${this.selectedAmount===c?"selected":""}" @click=${()=>this.selectAmount(c)}>$${c}</div>`)}
566
+ ${this.amounts.map(c=>J`<div class="chip ${this.selectedAmount===c?"selected":""}" @click=${()=>this.selectAmount(c)}>$${c}</div>`)}
488
567
  </div>
489
568
 
490
- ${o?q`
569
+ ${r?J`
491
570
  <div>
492
571
  <icpay-token-selector
493
572
  .options=${this.cryptoOptions}
@@ -505,19 +584,19 @@ var Re=Object.defineProperty;var Te=Object.getOwnPropertyDescriptor;var s=(n,a,e
505
584
  ${this.succeeded&&this.config?.disableAfterSuccess?"Paid":this.processing?"Processing\u2026":this.config?.buttonLabel?this.config.buttonLabel.replace("{amount}",String(this.selectedAmount)).replace("{symbol}",this.selectedSymbol):`Tip $${this.selectedAmount} with ${this.selectedSymbol}`}
506
585
  </button>
507
586
 
508
- ${this.errorMessage?q`
587
+ ${this.errorMessage?J`
509
588
  <div class="error-message ${this.errorSeverity}" style="margin-top: 12px; padding: 8px 12px; border-radius: 6px; font-size: 14px; text-align: center;">
510
589
  ${this.errorMessage}
511
- ${this.errorAction?q`
590
+ ${this.errorAction?J`
512
591
  <button style="margin-left: 8px; padding: 4px 8px; background: transparent; border: 1px solid currentColor; border-radius: 4px; font-size: 12px; cursor: pointer;">
513
592
  ${this.errorAction}
514
593
  </button>
515
594
  `:""}
516
595
  </div>
517
596
  `:""}
518
- ${(()=>{let b=(this.pnp?.getEnabledWallets?.()||[]).map(A=>({id:this.getWalletId(A),label:this.getWalletLabel(A),icon:this.getWalletIcon(A)}));return $({visible:!!(this.showWalletModal&&this.pnp),wallets:b,isConnecting:!1,onSelect:A=>this.connectWithWallet(A),onClose:()=>{this.showWalletModal=!1}})})()}
597
+ ${(()=>{let m=(this.pnp?.getEnabledWallets?.()||[]).map(O=>({id:this.getWalletId(O),label:this.getWalletLabel(O),icon:this.getWalletIcon(O)}));return M({visible:!!(this.showWalletModal&&this.pnp),wallets:m,isConnecting:!1,onSelect:O=>this.connectWithWallet(O),onClose:()=>{this.showWalletModal=!1}})})()}
519
598
  </div>
520
- `}};h.styles=[E,Ze`
599
+ `}};h.styles=[E,et`
521
600
  .jar { width: 120px; height: 160px; margin: 0 auto 12px; position: relative; background: linear-gradient(135deg, #374151 0%, #4b5563 100%); border-radius: 0 0 60px 60px; border: 3px solid #6b7280; border-top: 8px solid #6b7280; overflow: hidden; }
522
601
  .fill { position: absolute; bottom: 0; left: 0; right: 0; background: linear-gradient(135deg, #d1d5db 0%, #9ca3af 100%); transition: height 0.8s ease; height: 0%; }
523
602
  .amounts { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; margin: 12px 0; }
@@ -549,8 +628,8 @@ var Re=Object.defineProperty;var Te=Object.getOwnPropertyDescriptor;var s=(n,a,e
549
628
  border-color: rgba(239, 68, 68, 0.3);
550
629
  color: #ef4444;
551
630
  }
552
- `],s([et({type:Object})],h.prototype,"config",2),s([M()],h.prototype,"selectedAmount",2),s([M()],h.prototype,"selectedSymbol",2),s([M()],h.prototype,"total",2),s([M()],h.prototype,"processing",2),s([M()],h.prototype,"succeeded",2),s([M()],h.prototype,"availableLedgers",2),s([M()],h.prototype,"errorMessage",2),s([M()],h.prototype,"errorSeverity",2),s([M()],h.prototype,"errorAction",2),s([M()],h.prototype,"walletConnected",2),s([M()],h.prototype,"pendingAction",2),s([M()],h.prototype,"showWalletModal",2),h=s([Je("icpay-tip-jar")],h);import{LitElement as tt,html as ue,css as it}from"lit";import{customElement as st,property as be,state as R}from"lit/decorators.js";var xe=typeof window<"u",ie=null;function z(n,a,e){n&&(e!==void 0?console.log(`[ICPay Widget] ${a}`,e):console.log(`[ICPay Widget] ${a}`))}var g=class extends tt{constructor(){super(...arguments);this.title="Article Title";this.preview="";this.lockedContent="";this.selectedSymbol="ICP";this.unlocked=!1;this.succeeded=!1;this.processing=!1;this.availableLedgers=[];this.errorMessage=null;this.errorSeverity=null;this.errorAction=null;this.walletConnected=!1;this.pendingAction=null;this.showWalletModal=!1;this.pnp=null}get obfuscatedLockedContent(){try{return(this.lockedContent||"").replace(/[^\s]/g,"x")}catch{return"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"}}async tryAutoConnectPNP(){try{if(!this.config||this.config?.useOwnWallet)return;let e=localStorage.getItem("icpay:pnp");if(!e)return;let t=JSON.parse(e);if(!t?.provider||!t?.principal)return;ie||(ie=(await import("@windoge98/plug-n-play")).PNP);let i=new ie(this.config?.plugNPlay||{});this.walletConnected=!1,this.config={...this.config,connectedWallet:{owner:t.principal,principal:t.principal,connected:!1}}}catch{}}get cryptoOptions(){return this.config.cryptoOptions?this.config.cryptoOptions:this.availableLedgers}connectedCallback(){super.connectedCallback(),xe&&(z(this.config?.debug||!1,"Article paywall connected",{config:this.config}),this.config&&(typeof this.config.title=="string"&&(this.title=this.config.title),typeof this.config.preview=="string"&&(this.preview=this.config.preview),typeof this.config.lockedContent=="string"&&(this.lockedContent=this.config.lockedContent)),this.tryAutoConnectPNP(),this.config?.cryptoOptions&&this.config.cryptoOptions.length>0||this.loadVerifiedLedgers())}updated(e){if(e.has("config")&&this.config&&(typeof this.config.title=="string"&&(this.title=this.config.title),typeof this.config.preview=="string"&&(this.preview=this.config.preview),typeof this.config.lockedContent=="string"&&(this.lockedContent=this.config.lockedContent)),e.has("config")&&this.pendingAction&&this.config?.actorProvider){let t=this.pendingAction;this.pendingAction=null;try{window.dispatchEvent(new CustomEvent("icpay-sdk-wallet-connected",{detail:{walletType:"external"}}))}catch{}setTimeout(()=>{t==="unlock"&&this.unlock()},0)}}async loadVerifiedLedgers(){if(!(!xe||!this.config?.publishableKey))try{let t=await d(this.config).client.getVerifiedLedgers();this.availableLedgers=t.map(i=>({symbol:i.symbol,label:i.name,canisterId:i.canisterId})),this.selectedSymbol||(this.selectedSymbol=this.config?.defaultSymbol||this.availableLedgers[0]?.symbol||"ICP")}catch(e){console.warn("Failed to load verified ledgers:",e),this.availableLedgers=[{symbol:"ICP",label:"ICP",canisterId:"ryjl3-tyaaa-aaaaa-aaaba-cai"}],this.selectedSymbol||(this.selectedSymbol="ICP")}}selectSymbol(e){this.selectedSymbol=e}async unlock(){if(xe&&!(this.processing||this.unlocked)){z(this.config?.debug||!1,"Article paywall unlock started",{priceUsd:this.config.priceUsd,selectedSymbol:this.selectedSymbol,useOwnWallet:this.config.useOwnWallet}),this.errorMessage=null,this.errorSeverity=null,this.errorAction=null;try{window.dispatchEvent(new CustomEvent("icpay-sdk-method-start",{detail:{name:"unlock",type:"sendUsd",amount:this.config.priceUsd,currency:this.selectedSymbol}}))}catch{}this.processing=!0;try{if(this.config.useOwnWallet){if(!this.config.actorProvider){this.pendingAction="unlock",this.dispatchEvent(new CustomEvent("icpay-connect-wallet",{bubbles:!0}));return}}else if(!this.walletConnected){z(this.config?.debug||!1,"Connecting to wallet via Plug N Play");try{ie||(ie=(await import("@windoge98/plug-n-play")).PNP),this.pnp=new ie(this.config?.plugNPlay||{});let o=this.pnp.getEnabledWallets();if(z(this.config?.debug||!1,"Available wallets",o),!o?.length)throw new Error("No wallets available");this.pendingAction="unlock",this.showWalletModal=!0;return}catch(o){z(this.config?.debug||!1,"Wallet connection error:",o),this.errorMessage=o instanceof Error?o.message:"Wallet connection failed",this.errorSeverity="error";return}}z(this.config?.debug||!1,"Creating SDK for payment");let e=d(this.config),i=this.cryptoOptions.find(o=>o.symbol===this.selectedSymbol).canisterId||await e.client.getLedgerCanisterIdBySymbol(this.selectedSymbol);z(this.config?.debug||!1,"Article payment details",{priceUsd:this.config.priceUsd,selectedSymbol:this.selectedSymbol,canisterId:i});let r=await e.sendUsd(this.config.priceUsd,i,{context:"article"});z(this.config?.debug||!1,"Article payment completed",{resp:r}),this.unlocked=!0,this.succeeded=!0,this.config.onSuccess&&this.config.onSuccess({id:r.transactionId,status:r.status}),this.dispatchEvent(new CustomEvent("icpay-unlock",{detail:{amount:this.config.priceUsd,tx:r},bubbles:!0}))}catch(e){S(e,{onError:t=>{this.dispatchEvent(new CustomEvent("icpay-error",{detail:t,bubbles:!0})),W(t)&&(this.errorMessage=k(t),this.errorSeverity=L(t),this.errorAction=C(t))}})}finally{this.processing=!1}}}getWalletId(e){return e&&(e.id||e.provider||e.key)||""}getWalletLabel(e){return e&&(e.label||e.name||e.title||e.id)||"Wallet"}getWalletIcon(e){return e&&(e.icon||e.logo||e.image)||null}async connectWithWallet(e){if(this.pnp)try{if(!e)throw new Error("No wallet ID provided");let t=await this.pnp.connect(e);if(!!!(t&&(t.connected===!0||t.principal||t.owner||this.pnp?.account)))throw new Error("Wallet connection was rejected");this.walletConnected=!0;try{window.dispatchEvent(new CustomEvent("icpay-sdk-wallet-connected",{detail:{walletType:e}}))}catch{}this.config={...this.config,connectedWallet:t,actorProvider:(o,l)=>this.pnp.getActor({canisterId:o,idl:l,requiresSigning:!0,anon:!1})},this.showWalletModal=!1;let r=this.pendingAction;this.pendingAction=null,r==="unlock"&&setTimeout(()=>this.unlock(),0)}catch(t){this.errorMessage=t instanceof Error?t.message:"Wallet connection failed",this.errorSeverity="error",this.showWalletModal=!1}}render(){return this.config?ue`
553
- <div class="card section">
631
+ `],s([it({type:Object})],h.prototype,"config",2),s([I()],h.prototype,"selectedAmount",2),s([I()],h.prototype,"selectedSymbol",2),s([I()],h.prototype,"total",2),s([I()],h.prototype,"processing",2),s([I()],h.prototype,"succeeded",2),s([I()],h.prototype,"availableLedgers",2),s([I()],h.prototype,"errorMessage",2),s([I()],h.prototype,"errorSeverity",2),s([I()],h.prototype,"errorAction",2),s([I()],h.prototype,"walletConnected",2),s([I()],h.prototype,"pendingAction",2),s([I()],h.prototype,"showWalletModal",2),h=s([tt("icpay-tip-jar")],h);import{LitElement as st,html as ue,css as ot}from"lit";import{customElement as rt,property as me,state as P}from"lit/decorators.js";var xe=typeof window<"u",oe=null;function j(n,a,e){n&&(e!==void 0?console.log(`[ICPay Widget] ${a}`,e):console.log(`[ICPay Widget] ${a}`))}var g=class extends st{constructor(){super(...arguments);this.title="Article Title";this.preview="";this.lockedContent="";this.selectedSymbol="ICP";this.unlocked=!1;this.succeeded=!1;this.processing=!1;this.availableLedgers=[];this.errorMessage=null;this.errorSeverity=null;this.errorAction=null;this.walletConnected=!1;this.pendingAction=null;this.showWalletModal=!1;this.pnp=null}get obfuscatedLockedContent(){try{return(this.lockedContent||"").replace(/[^\s]/g,"x")}catch{return"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"}}async tryAutoConnectPNP(){try{if(!this.config||this.config?.useOwnWallet)return;let e=localStorage.getItem("icpay:pnp");if(!e)return;let t=JSON.parse(e);if(!t?.provider||!t?.principal)return;oe||(oe=(await import("@windoge98/plug-n-play")).PNP);let i=new oe(this.config?.plugNPlay||{});this.walletConnected=!1,this.config={...this.config,connectedWallet:{owner:t.principal,principal:t.principal,connected:!1}}}catch{}}get cryptoOptions(){return this.config.cryptoOptions?this.config.cryptoOptions:this.availableLedgers}connectedCallback(){super.connectedCallback(),xe&&(j(this.config?.debug||!1,"Article paywall connected",{config:this.config}),this.config&&(typeof this.config.title=="string"&&(this.title=this.config.title),typeof this.config.preview=="string"&&(this.preview=this.config.preview),typeof this.config.lockedContent=="string"&&(this.lockedContent=this.config.lockedContent)),this.tryAutoConnectPNP(),this.config?.cryptoOptions&&this.config.cryptoOptions.length>0||this.loadVerifiedLedgers())}updated(e){if(e.has("config")&&this.config&&(typeof this.config.title=="string"&&(this.title=this.config.title),typeof this.config.preview=="string"&&(this.preview=this.config.preview),typeof this.config.lockedContent=="string"&&(this.lockedContent=this.config.lockedContent)),e.has("config")&&this.pendingAction&&this.config?.actorProvider){let t=this.pendingAction;this.pendingAction=null;try{window.dispatchEvent(new CustomEvent("icpay-sdk-wallet-connected",{detail:{walletType:"external"}}))}catch{}setTimeout(()=>{t==="unlock"&&this.unlock()},0)}}async loadVerifiedLedgers(){if(!(!xe||!this.config?.publishableKey))try{let t=await d(this.config).client.getVerifiedLedgers();this.availableLedgers=t.map(i=>({symbol:i.symbol,label:i.name,canisterId:i.canisterId})),this.selectedSymbol||(this.selectedSymbol=this.config?.defaultSymbol||this.availableLedgers[0]?.symbol||"ICP")}catch(e){console.warn("Failed to load verified ledgers:",e),this.availableLedgers=[{symbol:"ICP",label:"ICP",canisterId:"ryjl3-tyaaa-aaaaa-aaaba-cai"}],this.selectedSymbol||(this.selectedSymbol="ICP")}}selectSymbol(e){this.selectedSymbol=e}async unlock(){if(xe&&!(this.processing||this.unlocked)){j(this.config?.debug||!1,"Article paywall unlock started",{priceUsd:this.config.priceUsd,selectedSymbol:this.selectedSymbol,useOwnWallet:this.config.useOwnWallet}),this.errorMessage=null,this.errorSeverity=null,this.errorAction=null;try{window.dispatchEvent(new CustomEvent("icpay-sdk-method-start",{detail:{name:"unlock",type:"sendUsd",amount:this.config.priceUsd,currency:this.selectedSymbol}}))}catch{}this.processing=!0;try{if(this.config.useOwnWallet){if(!this.config.actorProvider){this.pendingAction="unlock",this.dispatchEvent(new CustomEvent("icpay-connect-wallet",{bubbles:!0}));return}}else if(!this.walletConnected){j(this.config?.debug||!1,"Connecting to wallet via Plug N Play");try{oe||(oe=(await import("@windoge98/plug-n-play")).PNP),this.pnp=new oe(this.config?.plugNPlay||{});let r=this.pnp.getEnabledWallets();if(j(this.config?.debug||!1,"Available wallets",r),!r?.length)throw new Error("No wallets available");this.pendingAction="unlock",this.showWalletModal=!0;return}catch(r){j(this.config?.debug||!1,"Wallet connection error:",r),this.errorMessage=r instanceof Error?r.message:"Wallet connection failed",this.errorSeverity="error";return}}j(this.config?.debug||!1,"Creating SDK for payment");let e=d(this.config),i=this.cryptoOptions.find(r=>r.symbol===this.selectedSymbol).canisterId||await e.client.getLedgerCanisterIdBySymbol(this.selectedSymbol);j(this.config?.debug||!1,"Article payment details",{priceUsd:this.config.priceUsd,selectedSymbol:this.selectedSymbol,canisterId:i});let o=await e.sendUsd(this.config.priceUsd,i,{context:"article"});j(this.config?.debug||!1,"Article payment completed",{resp:o}),this.unlocked=!0,this.succeeded=!0,this.config.onSuccess&&this.config.onSuccess({id:o.transactionId,status:o.status}),this.dispatchEvent(new CustomEvent("icpay-unlock",{detail:{amount:this.config.priceUsd,tx:o},bubbles:!0}))}catch(e){S(e,{onError:t=>{this.dispatchEvent(new CustomEvent("icpay-error",{detail:t,bubbles:!0})),W(t)&&(this.errorMessage=k(t),this.errorSeverity=A(t),this.errorAction=L(t))}})}finally{this.processing=!1}}}getWalletId(e){return e&&(e.id||e.provider||e.key)||""}getWalletLabel(e){return e&&(e.label||e.name||e.title||e.id)||"Wallet"}getWalletIcon(e){return e&&(e.icon||e.logo||e.image)||null}async connectWithWallet(e){if(this.pnp)try{if(!e)throw new Error("No wallet ID provided");let t=await this.pnp.connect(e);if(!!!(t&&(t.connected===!0||t.principal||t.owner||this.pnp?.account)))throw new Error("Wallet connection was rejected");this.walletConnected=!0;try{window.dispatchEvent(new CustomEvent("icpay-sdk-wallet-connected",{detail:{walletType:e}}))}catch{}this.config={...this.config,connectedWallet:t,actorProvider:(r,l)=>this.pnp.getActor({canisterId:r,idl:l,requiresSigning:!0,anon:!1})},this.showWalletModal=!1;let o=this.pendingAction;this.pendingAction=null,o==="unlock"&&setTimeout(()=>this.unlock(),0)}catch(t){this.errorMessage=t instanceof Error?t.message:"Wallet connection failed",this.errorSeverity="error",this.showWalletModal=!1}}render(){return this.config?ue`
632
+ <div class="icpay-card icpay-section">
554
633
  ${this.config?.progressBar?.enabled!==!1?ue`<icpay-progress-bar mode="${this.config?.progressBar?.mode||"modal"}"></icpay-progress-bar>`:null}
555
634
  <div class="container">
556
635
  <div class="title">${this.title}</div>
@@ -584,9 +663,9 @@ var Re=Object.defineProperty;var Te=Object.getOwnPropertyDescriptor;var s=(n,a,e
584
663
  `:""}
585
664
  </div>
586
665
  `:""}
587
- ${(()=>{let t=(this.pnp?.getEnabledWallets?.()||[]).map(i=>({id:this.getWalletId(i),label:this.getWalletLabel(i),icon:this.getWalletIcon(i)}));return $({visible:!!(this.showWalletModal&&this.pnp),wallets:t,isConnecting:!1,onSelect:i=>this.connectWithWallet(i),onClose:()=>{this.showWalletModal=!1}})})()}
666
+ ${(()=>{let t=(this.pnp?.getEnabledWallets?.()||[]).map(i=>({id:this.getWalletId(i),label:this.getWalletLabel(i),icon:this.getWalletIcon(i)}));return M({visible:!!(this.showWalletModal&&this.pnp),wallets:t,isConnecting:!1,onSelect:i=>this.connectWithWallet(i),onClose:()=>{this.showWalletModal=!1}})})()}
588
667
  </div>
589
- `:ue`<div class="card section">Loading...</div>`}};g.styles=[E,it`
668
+ `:ue`<div class="icpay-card icpay-section">Loading...</div>`}};g.styles=[E,ot`
590
669
  .container { background: var(--icpay-surface-alt); border: 1px solid var(--icpay-border); border-radius: 16px; padding: 16px; margin-bottom: 16px; }
591
670
  .title { color: var(--icpay-text); font-weight: 700; margin-bottom: 8px; }
592
671
  .preview { color: var(--icpay-muted); margin-bottom: 12px; line-height: 1.6; }
@@ -618,11 +697,11 @@ var Re=Object.defineProperty;var Te=Object.getOwnPropertyDescriptor;var s=(n,a,e
618
697
  border-color: rgba(239, 68, 68, 0.3);
619
698
  color: #ef4444;
620
699
  }
621
- `],s([be({type:Object})],g.prototype,"config",2),s([be({type:String})],g.prototype,"title",2),s([be({type:String})],g.prototype,"preview",2),s([be({type:String})],g.prototype,"lockedContent",2),s([R()],g.prototype,"selectedSymbol",2),s([R()],g.prototype,"unlocked",2),s([R()],g.prototype,"succeeded",2),s([R()],g.prototype,"processing",2),s([R()],g.prototype,"availableLedgers",2),s([R()],g.prototype,"errorMessage",2),s([R()],g.prototype,"errorSeverity",2),s([R()],g.prototype,"errorAction",2),s([R()],g.prototype,"walletConnected",2),s([R()],g.prototype,"pendingAction",2),s([R()],g.prototype,"showWalletModal",2),g=s([st("icpay-article-paywall")],g);import{LitElement as rt,html as se,css as nt}from"lit";import{customElement as ot,property as at,state as K}from"lit/decorators.js";var Ee=typeof window<"u",Se=null;function V(n,a,e){n&&(e!==void 0?console.log(`[ICPay Widget] ${a}`,e):console.log(`[ICPay Widget] ${a}`))}var v=class extends rt{constructor(){super(...arguments);this.selectedIndex=0;this.selectedSymbol="ICP";this.processing=!1;this.availableLedgers=[];this.errorMessage=null;this.errorSeverity=null;this.errorAction=null;this.walletConnected=!1;this.pendingAction=null;this.showWalletModal=!1;this.pnp=null}get cryptoOptions(){return this.config.cryptoOptions?this.config.cryptoOptions:this.availableLedgers}connectedCallback(){super.connectedCallback(),Ee&&(V(this.config?.debug||!1,"Coffee shop connected",{config:this.config}),this.config&&typeof this.config.defaultItemIndex=="number"&&(this.selectedIndex=this.config.defaultItemIndex),this.config?.cryptoOptions&&this.config.cryptoOptions.length>0||this.loadVerifiedLedgers())}updated(e){if(e.has("config")&&this.pendingAction&&this.config?.actorProvider){let t=this.pendingAction;this.pendingAction=null;try{window.dispatchEvent(new CustomEvent("icpay-sdk-wallet-connected",{detail:{walletType:"external"}}))}catch{}setTimeout(()=>{t==="order"&&this.order()},0)}}async loadVerifiedLedgers(){if(!(!Ee||!this.config?.publishableKey))try{let t=await d(this.config).client.getVerifiedLedgers();this.availableLedgers=t.map(i=>({symbol:i.symbol,label:i.name,canisterId:i.canisterId})),this.availableLedgers.length>0&&!this.selectedSymbol&&(this.selectedSymbol=this.availableLedgers[0].symbol)}catch(e){console.warn("Failed to load verified ledgers:",e),this.availableLedgers=[{symbol:"ICP",label:"ICP",canisterId:"ryjl3-tyaaa-aaaaa-aaaba-cai"}],this.selectedSymbol||(this.selectedSymbol="ICP")}}selectItem(e){this.selectedIndex=e}selectSymbol(e){this.selectedSymbol=e}get selectedItem(){return this.config?.items?.[this.selectedIndex]||{name:"Loading...",priceUsd:0}}async order(){if(Ee&&!this.processing){V(this.config?.debug||!1,"Coffee order started",{selectedItem:this.selectedItem,selectedSymbol:this.selectedSymbol,useOwnWallet:this.config.useOwnWallet}),this.errorMessage=null,this.errorSeverity=null,this.errorAction=null;try{window.dispatchEvent(new CustomEvent("icpay-sdk-method-start",{detail:{name:"order",type:"sendUsd",amount:this.selectedItem.priceUsd,currency:this.selectedSymbol}}))}catch{}this.processing=!0;try{if(this.config.useOwnWallet){if(!this.config.actorProvider){this.pendingAction="order",this.dispatchEvent(new CustomEvent("icpay-connect-wallet",{bubbles:!0}));return}}else if(!this.walletConnected){V(this.config?.debug||!1,"Connecting to wallet via Plug N Play");try{Se||(Se=(await import("@windoge98/plug-n-play")).PNP),this.pnp=new Se(this.config?.plugNPlay||{});let o=this.pnp.getEnabledWallets();if(V(this.config?.debug||!1,"Available wallets",o),!o?.length)throw new Error("No wallets available");this.pendingAction="order",this.showWalletModal=!0;return}catch(o){V(this.config?.debug||!1,"Wallet connection error:",o),this.errorMessage=o instanceof Error?o.message:"Wallet connection failed",this.errorSeverity="error";return}}V(this.config?.debug||!1,"Creating SDK for payment");let e=d(this.config),i=this.cryptoOptions.find(o=>o.symbol===this.selectedSymbol).canisterId||await e.client.getLedgerCanisterIdBySymbol(this.selectedSymbol);V(this.config?.debug||!1,"Coffee order payment details",{item:this.selectedItem.name,priceUsd:this.selectedItem.priceUsd,selectedSymbol:this.selectedSymbol,canisterId:i});let r=await e.sendUsd(this.selectedItem.priceUsd,i,{context:"coffee",item:this.selectedItem.name});V(this.config?.debug||!1,"Coffee order payment completed",{resp:r}),this.config.onSuccess&&this.config.onSuccess({id:r.transactionId,status:r.status,item:this.selectedItem.name}),this.dispatchEvent(new CustomEvent("icpay-coffee",{detail:{item:this.selectedItem,tx:r},bubbles:!0}))}catch(e){S(e,{onError:t=>{this.dispatchEvent(new CustomEvent("icpay-error",{detail:t,bubbles:!0})),W(t)&&(this.errorMessage=k(t),this.errorSeverity=L(t),this.errorAction=C(t))}})}finally{this.processing=!1}}}getWalletId(e){return e&&(e.id||e.provider||e.key)||""}getWalletLabel(e){return e&&(e.label||e.name||e.title||e.id)||"Wallet"}getWalletIcon(e){return e&&(e.icon||e.logo||e.image)||null}async connectWithWallet(e){if(this.pnp)try{if(!e)throw new Error("No wallet ID provided");let t=await this.pnp.connect(e);if(!!!(t&&(t.connected===!0||t.principal||t.owner||this.pnp?.account)))throw new Error("Wallet connection was rejected");this.walletConnected=!0;try{window.dispatchEvent(new CustomEvent("icpay-sdk-wallet-connected",{detail:{walletType:e}}))}catch{}this.config={...this.config,connectedWallet:t,actorProvider:(o,l)=>this.pnp.getActor({canisterId:o,idl:l,requiresSigning:!0,anon:!1})},this.showWalletModal=!1;let r=this.pendingAction;this.pendingAction=null,r==="order"&&setTimeout(()=>this.order(),0)}catch(t){this.errorMessage=t instanceof Error?t.message:"Wallet connection failed",this.errorSeverity="error",this.showWalletModal=!1}}render(){return this.config?se`
622
- <div class="card section">
623
- ${this.config?.progressBar?.enabled!==!1?se`<icpay-progress-bar mode="${this.config?.progressBar?.mode||"modal"}"></icpay-progress-bar>`:null}
700
+ `],s([me({type:Object})],g.prototype,"config",2),s([me({type:String})],g.prototype,"title",2),s([me({type:String})],g.prototype,"preview",2),s([me({type:String})],g.prototype,"lockedContent",2),s([P()],g.prototype,"selectedSymbol",2),s([P()],g.prototype,"unlocked",2),s([P()],g.prototype,"succeeded",2),s([P()],g.prototype,"processing",2),s([P()],g.prototype,"availableLedgers",2),s([P()],g.prototype,"errorMessage",2),s([P()],g.prototype,"errorSeverity",2),s([P()],g.prototype,"errorAction",2),s([P()],g.prototype,"walletConnected",2),s([P()],g.prototype,"pendingAction",2),s([P()],g.prototype,"showWalletModal",2),g=s([rt("icpay-article-paywall")],g);import{LitElement as nt,html as re,css as at}from"lit";import{customElement as lt,property as ct,state as D}from"lit/decorators.js";var Ee=typeof window<"u",Se=null;function G(n,a,e){n&&(e!==void 0?console.log(`[ICPay Widget] ${a}`,e):console.log(`[ICPay Widget] ${a}`))}var v=class extends nt{constructor(){super(...arguments);this.selectedIndex=0;this.selectedSymbol="ICP";this.processing=!1;this.availableLedgers=[];this.errorMessage=null;this.errorSeverity=null;this.errorAction=null;this.walletConnected=!1;this.pendingAction=null;this.showWalletModal=!1;this.pnp=null}get cryptoOptions(){return this.config.cryptoOptions?this.config.cryptoOptions:this.availableLedgers}connectedCallback(){super.connectedCallback(),Ee&&(G(this.config?.debug||!1,"Coffee shop connected",{config:this.config}),this.config&&typeof this.config.defaultItemIndex=="number"&&(this.selectedIndex=this.config.defaultItemIndex),this.config?.cryptoOptions&&this.config.cryptoOptions.length>0||this.loadVerifiedLedgers())}updated(e){if(e.has("config")&&this.pendingAction&&this.config?.actorProvider){let t=this.pendingAction;this.pendingAction=null;try{window.dispatchEvent(new CustomEvent("icpay-sdk-wallet-connected",{detail:{walletType:"external"}}))}catch{}setTimeout(()=>{t==="order"&&this.order()},0)}}async loadVerifiedLedgers(){if(!(!Ee||!this.config?.publishableKey))try{let t=await d(this.config).client.getVerifiedLedgers();this.availableLedgers=t.map(i=>({symbol:i.symbol,label:i.name,canisterId:i.canisterId})),this.availableLedgers.length>0&&!this.selectedSymbol&&(this.selectedSymbol=this.availableLedgers[0].symbol)}catch(e){console.warn("Failed to load verified ledgers:",e),this.availableLedgers=[{symbol:"ICP",label:"ICP",canisterId:"ryjl3-tyaaa-aaaaa-aaaba-cai"}],this.selectedSymbol||(this.selectedSymbol="ICP")}}selectItem(e){this.selectedIndex=e}selectSymbol(e){this.selectedSymbol=e}get selectedItem(){return this.config?.items?.[this.selectedIndex]||{name:"Loading...",priceUsd:0}}async order(){if(Ee&&!this.processing){G(this.config?.debug||!1,"Coffee order started",{selectedItem:this.selectedItem,selectedSymbol:this.selectedSymbol,useOwnWallet:this.config.useOwnWallet}),this.errorMessage=null,this.errorSeverity=null,this.errorAction=null;try{window.dispatchEvent(new CustomEvent("icpay-sdk-method-start",{detail:{name:"order",type:"sendUsd",amount:this.selectedItem.priceUsd,currency:this.selectedSymbol}}))}catch{}this.processing=!0;try{if(this.config.useOwnWallet){if(!this.config.actorProvider){this.pendingAction="order",this.dispatchEvent(new CustomEvent("icpay-connect-wallet",{bubbles:!0}));return}}else if(!this.walletConnected){G(this.config?.debug||!1,"Connecting to wallet via Plug N Play");try{Se||(Se=(await import("@windoge98/plug-n-play")).PNP),this.pnp=new Se(this.config?.plugNPlay||{});let r=this.pnp.getEnabledWallets();if(G(this.config?.debug||!1,"Available wallets",r),!r?.length)throw new Error("No wallets available");this.pendingAction="order",this.showWalletModal=!0;return}catch(r){G(this.config?.debug||!1,"Wallet connection error:",r),this.errorMessage=r instanceof Error?r.message:"Wallet connection failed",this.errorSeverity="error";return}}G(this.config?.debug||!1,"Creating SDK for payment");let e=d(this.config),i=this.cryptoOptions.find(r=>r.symbol===this.selectedSymbol).canisterId||await e.client.getLedgerCanisterIdBySymbol(this.selectedSymbol);G(this.config?.debug||!1,"Coffee order payment details",{item:this.selectedItem.name,priceUsd:this.selectedItem.priceUsd,selectedSymbol:this.selectedSymbol,canisterId:i});let o=await e.sendUsd(this.selectedItem.priceUsd,i,{context:"coffee",item:this.selectedItem.name});G(this.config?.debug||!1,"Coffee order payment completed",{resp:o}),this.config.onSuccess&&this.config.onSuccess({id:o.transactionId,status:o.status,item:this.selectedItem.name}),this.dispatchEvent(new CustomEvent("icpay-coffee",{detail:{item:this.selectedItem,tx:o},bubbles:!0}))}catch(e){S(e,{onError:t=>{this.dispatchEvent(new CustomEvent("icpay-error",{detail:t,bubbles:!0})),W(t)&&(this.errorMessage=k(t),this.errorSeverity=A(t),this.errorAction=L(t))}})}finally{this.processing=!1}}}getWalletId(e){return e&&(e.id||e.provider||e.key)||""}getWalletLabel(e){return e&&(e.label||e.name||e.title||e.id)||"Wallet"}getWalletIcon(e){return e&&(e.icon||e.logo||e.image)||null}async connectWithWallet(e){if(this.pnp)try{if(!e)throw new Error("No wallet ID provided");let t=await this.pnp.connect(e);if(!!!(t&&(t.connected===!0||t.principal||t.owner||this.pnp?.account)))throw new Error("Wallet connection was rejected");this.walletConnected=!0;try{window.dispatchEvent(new CustomEvent("icpay-sdk-wallet-connected",{detail:{walletType:e}}))}catch{}this.config={...this.config,connectedWallet:t,actorProvider:(r,l)=>this.pnp.getActor({canisterId:r,idl:l,requiresSigning:!0,anon:!1})},this.showWalletModal=!1;let o=this.pendingAction;this.pendingAction=null,o==="order"&&setTimeout(()=>this.order(),0)}catch(t){this.errorMessage=t instanceof Error?t.message:"Wallet connection failed",this.errorSeverity="error",this.showWalletModal=!1}}render(){return this.config?re`
701
+ <div class="icpay-card icpay-section">
702
+ ${this.config?.progressBar?.enabled!==!1?re`<icpay-progress-bar mode="${this.config?.progressBar?.mode||"modal"}"></icpay-progress-bar>`:null}
624
703
  <div class="menu">
625
- ${this.config.items.map((e,t)=>se`
704
+ ${this.config.items.map((e,t)=>re`
626
705
  <div class="item ${this.selectedIndex===t?"selected":""}" @click=${()=>this.selectItem(t)}>
627
706
  <span>${e.name}</span>
628
707
  <span>$${Number(e?.priceUsd??0).toFixed(2)}</span>
@@ -646,19 +725,19 @@ var Re=Object.defineProperty;var Te=Object.getOwnPropertyDescriptor;var s=(n,a,e
646
725
  ${this.processing?"Processing\u2026":`Order ${this.selectedItem.name}`}
647
726
  </button>
648
727
 
649
- ${this.errorMessage?se`
728
+ ${this.errorMessage?re`
650
729
  <div class="error-message ${this.errorSeverity}" style="margin-top: 12px; padding: 8px 12px; border-radius: 6px; font-size: 14px; text-align: center;">
651
730
  ${this.errorMessage}
652
- ${this.errorAction?se`
731
+ ${this.errorAction?re`
653
732
  <button style="margin-left: 8px; padding: 4px 8px; background: transparent; border: 1px solid currentColor; border-radius: 4px; font-size: 12px; cursor: pointer;">
654
733
  ${this.errorAction}
655
734
  </button>
656
735
  `:""}
657
736
  </div>
658
737
  `:""}
659
- ${(()=>{let t=(this.pnp?.getEnabledWallets?.()||[]).map(i=>({id:this.getWalletId(i),label:this.getWalletLabel(i),icon:this.getWalletIcon(i)}));return $({visible:!!(this.showWalletModal&&this.pnp),wallets:t,isConnecting:!1,onSelect:i=>this.connectWithWallet(i),onClose:()=>{this.showWalletModal=!1}})})()}
738
+ ${(()=>{let t=(this.pnp?.getEnabledWallets?.()||[]).map(i=>({id:this.getWalletId(i),label:this.getWalletLabel(i),icon:this.getWalletIcon(i)}));return M({visible:!!(this.showWalletModal&&this.pnp),wallets:t,isConnecting:!1,onSelect:i=>this.connectWithWallet(i),onClose:()=>{this.showWalletModal=!1}})})()}
660
739
  </div>
661
- `:se`<div class="card section">Loading...</div>`}};v.styles=[E,nt`
740
+ `:re`<div class="icpay-card icpay-section">Loading...</div>`}};v.styles=[E,at`
662
741
  .menu { display: grid; gap: 8px; margin-bottom: 12px; }
663
742
  .item { background: var(--icpay-surface-alt); border: 2px solid var(--icpay-border); border-radius: 12px; padding: 16px; display:flex; justify-content: space-between; align-items:center; cursor: pointer; color: var(--icpay-text); font-weight: 600; }
664
743
  .item.selected { background: var(--icpay-primary); color: #111827; border-color: var(--icpay-primary); }
@@ -689,14 +768,14 @@ var Re=Object.defineProperty;var Te=Object.getOwnPropertyDescriptor;var s=(n,a,e
689
768
  border-color: rgba(239, 68, 68, 0.3);
690
769
  color: #ef4444;
691
770
  }
692
- `],s([at({type:Object})],v.prototype,"config",2),s([K()],v.prototype,"selectedIndex",2),s([K()],v.prototype,"selectedSymbol",2),s([K()],v.prototype,"processing",2),s([K()],v.prototype,"availableLedgers",2),s([K()],v.prototype,"errorMessage",2),s([K()],v.prototype,"errorSeverity",2),s([K()],v.prototype,"errorAction",2),s([K()],v.prototype,"walletConnected",2),s([K()],v.prototype,"pendingAction",2),s([K()],v.prototype,"showWalletModal",2),v=s([ot("icpay-coffee-shop")],v);import{LitElement as lt,html as re,css as ct}from"lit";import{customElement as dt,property as pt,state as O}from"lit/decorators.js";var ke=typeof window<"u",ne=null;function H(n,a,e){n&&(e!==void 0?console.log(`[ICPay Widget] ${a}`,e):console.log(`[ICPay Widget] ${a}`))}var u=class extends lt{constructor(){super(...arguments);this.selectedAmount=10;this.selectedSymbol="ICP";this.raised=0;this.processing=!1;this.succeeded=!1;this.availableLedgers=[];this.errorMessage=null;this.errorSeverity=null;this.errorAction=null;this.walletConnected=!1;this.pendingAction=null;this.showWalletModal=!1;this.pnp=null}async tryAutoConnectPNP(){try{if(!this.config||this.config?.useOwnWallet)return;let e=localStorage.getItem("icpay:pnp");if(!e)return;let t=JSON.parse(e);if(!t?.provider||!t?.principal)return;ne||(ne=(await import("@windoge98/plug-n-play")).PNP);let i=new ne(this.config?.plugNPlay||{});this.walletConnected=!1,this.config={...this.config,connectedWallet:{owner:t.principal,principal:t.principal,connected:!1}}}catch{}}get amounts(){return this.config?.amountsUsd||[10,25,50,100,250,500]}get cryptoOptions(){return this.config.cryptoOptions?this.config.cryptoOptions:this.availableLedgers}connectedCallback(){super.connectedCallback(),ke&&(H(this.config?.debug||!1,"Donation thermometer connected",{config:this.config}),this.config&&typeof this.config.defaultAmountUsd=="number"&&(this.selectedAmount=this.config.defaultAmountUsd),this.tryAutoConnectPNP(),this.config?.cryptoOptions&&this.config.cryptoOptions.length>0||this.loadVerifiedLedgers())}updated(e){if(e.has("config")&&this.pendingAction&&this.config?.actorProvider){let t=this.pendingAction;this.pendingAction=null;try{window.dispatchEvent(new CustomEvent("icpay-sdk-wallet-connected",{detail:{walletType:"external"}}))}catch{}setTimeout(()=>{t==="donate"&&this.donate()},0)}}async loadVerifiedLedgers(){if(!(!ke||!this.config?.publishableKey))try{let t=await d(this.config).client.getVerifiedLedgers();this.availableLedgers=t.map(i=>({symbol:i.symbol,label:i.name,canisterId:i.canisterId})),this.availableLedgers.length>0&&!this.selectedSymbol&&(this.selectedSymbol=this.availableLedgers[0].symbol)}catch(e){console.warn("Failed to load verified ledgers:",e),this.availableLedgers=[{symbol:"ICP",label:"ICP",canisterId:"ryjl3-tyaaa-aaaaa-aaaba-cai"}],this.selectedSymbol||(this.selectedSymbol="ICP")}}selectAmount(e){this.selectedAmount=e}selectSymbol(e){this.selectedSymbol=e}get fillPercentage(){let e=Number(this.config?.goalUsd??1e3),t=e>0?e:1e3;return Math.min(this.raised/t*100,100)}async donate(){if(ke&&!this.processing){H(this.config?.debug||!1,"Donation started",{amount:this.selectedAmount,selectedSymbol:this.selectedSymbol,useOwnWallet:this.config.useOwnWallet}),this.errorMessage=null,this.errorSeverity=null,this.errorAction=null;try{window.dispatchEvent(new CustomEvent("icpay-sdk-method-start",{detail:{name:"donate",type:"sendUsd",amount:this.selectedAmount,currency:this.selectedSymbol}}))}catch{}this.processing=!0;try{if(this.config.useOwnWallet){if(!this.config.actorProvider){this.pendingAction="donate",this.dispatchEvent(new CustomEvent("icpay-connect-wallet",{bubbles:!0}));return}}else if(!this.walletConnected){H(this.config?.debug||!1,"Connecting to wallet via Plug N Play");try{ne||(ne=(await import("@windoge98/plug-n-play")).PNP),this.pnp=new ne(this.config?.plugNPlay||{});let o=this.pnp.getEnabledWallets();if(H(this.config?.debug||!1,"Available wallets",o),!o?.length)throw new Error("No wallets available");this.pendingAction="donate",this.showWalletModal=!0;return}catch(o){H(this.config?.debug||!1,"Wallet connection error:",o),this.errorMessage=o instanceof Error?o.message:"Wallet connection failed",this.errorSeverity="error";return}}H(this.config?.debug||!1,"Creating SDK for payment");let e=d(this.config),i=this.cryptoOptions.find(o=>o.symbol===this.selectedSymbol).canisterId||await e.client.getLedgerCanisterIdBySymbol(this.selectedSymbol);H(this.config?.debug||!1,"Donation payment details",{amount:this.selectedAmount,selectedSymbol:this.selectedSymbol,canisterId:i});let r=await e.sendUsd(this.selectedAmount,i,{context:"donation"});H(this.config?.debug||!1,"Donation payment completed",{resp:r}),this.raised+=this.selectedAmount,this.succeeded=!0,this.config.onSuccess&&this.config.onSuccess({id:r.transactionId,status:r.status,raised:this.raised}),this.dispatchEvent(new CustomEvent("icpay-donation",{detail:{amount:this.selectedAmount,tx:r},bubbles:!0}))}catch(e){S(e,{onError:t=>{this.dispatchEvent(new CustomEvent("icpay-error",{detail:t,bubbles:!0})),W(t)&&(this.errorMessage=k(t),this.errorSeverity=L(t),this.errorAction=C(t))}})}finally{this.processing=!1}}}getWalletId(e){return e&&(e.id||e.provider||e.key)||""}getWalletLabel(e){return e&&(e.label||e.name||e.title||e.id)||"Wallet"}getWalletIcon(e){return e&&(e.icon||e.logo||e.image)||null}async connectWithWallet(e){if(this.pnp)try{if(!e)throw new Error("No wallet ID provided");let t=await this.pnp.connect(e);if(!!!(t&&(t.connected===!0||t.principal||t.owner||this.pnp?.account)))throw new Error("Wallet connection was rejected");this.walletConnected=!0;try{window.dispatchEvent(new CustomEvent("icpay-sdk-wallet-connected",{detail:{walletType:e}}))}catch{}this.config={...this.config,connectedWallet:t,actorProvider:(o,l)=>this.pnp.getActor({canisterId:o,idl:l,requiresSigning:!0,anon:!1})},this.showWalletModal=!1;let r=this.pendingAction;this.pendingAction=null,r==="donate"&&setTimeout(()=>this.donate(),0)}catch(t){this.errorMessage=t instanceof Error?t.message:"Wallet connection failed",this.errorSeverity="error",this.showWalletModal=!1}}render(){return this.config?re`
693
- <div class="card section" style="text-align:center;">
694
- ${this.config?.progressBar?.enabled!==!1?re`<icpay-progress-bar mode="${this.config?.progressBar?.mode||"modal"}"></icpay-progress-bar>`:null}
771
+ `],s([ct({type:Object})],v.prototype,"config",2),s([D()],v.prototype,"selectedIndex",2),s([D()],v.prototype,"selectedSymbol",2),s([D()],v.prototype,"processing",2),s([D()],v.prototype,"availableLedgers",2),s([D()],v.prototype,"errorMessage",2),s([D()],v.prototype,"errorSeverity",2),s([D()],v.prototype,"errorAction",2),s([D()],v.prototype,"walletConnected",2),s([D()],v.prototype,"pendingAction",2),s([D()],v.prototype,"showWalletModal",2),v=s([lt("icpay-coffee-shop")],v);import{LitElement as dt,html as ne,css as pt}from"lit";import{customElement as gt,property as ht,state as N}from"lit/decorators.js";var ke=typeof window<"u",ae=null;function Y(n,a,e){n&&(e!==void 0?console.log(`[ICPay Widget] ${a}`,e):console.log(`[ICPay Widget] ${a}`))}var u=class extends dt{constructor(){super(...arguments);this.selectedAmount=10;this.selectedSymbol="ICP";this.raised=0;this.processing=!1;this.succeeded=!1;this.availableLedgers=[];this.errorMessage=null;this.errorSeverity=null;this.errorAction=null;this.walletConnected=!1;this.pendingAction=null;this.showWalletModal=!1;this.pnp=null}async tryAutoConnectPNP(){try{if(!this.config||this.config?.useOwnWallet)return;let e=localStorage.getItem("icpay:pnp");if(!e)return;let t=JSON.parse(e);if(!t?.provider||!t?.principal)return;ae||(ae=(await import("@windoge98/plug-n-play")).PNP);let i=new ae(this.config?.plugNPlay||{});this.walletConnected=!1,this.config={...this.config,connectedWallet:{owner:t.principal,principal:t.principal,connected:!1}}}catch{}}get amounts(){return this.config?.amountsUsd||[10,25,50,100,250,500]}get cryptoOptions(){return this.config.cryptoOptions?this.config.cryptoOptions:this.availableLedgers}connectedCallback(){super.connectedCallback(),ke&&(Y(this.config?.debug||!1,"Donation thermometer connected",{config:this.config}),this.config&&typeof this.config.defaultAmountUsd=="number"&&(this.selectedAmount=this.config.defaultAmountUsd),this.tryAutoConnectPNP(),this.config?.cryptoOptions&&this.config.cryptoOptions.length>0||this.loadVerifiedLedgers())}updated(e){if(e.has("config")&&this.pendingAction&&this.config?.actorProvider){let t=this.pendingAction;this.pendingAction=null;try{window.dispatchEvent(new CustomEvent("icpay-sdk-wallet-connected",{detail:{walletType:"external"}}))}catch{}setTimeout(()=>{t==="donate"&&this.donate()},0)}}async loadVerifiedLedgers(){if(!(!ke||!this.config?.publishableKey))try{let t=await d(this.config).client.getVerifiedLedgers();this.availableLedgers=t.map(i=>({symbol:i.symbol,label:i.name,canisterId:i.canisterId})),this.availableLedgers.length>0&&!this.selectedSymbol&&(this.selectedSymbol=this.availableLedgers[0].symbol)}catch(e){console.warn("Failed to load verified ledgers:",e),this.availableLedgers=[{symbol:"ICP",label:"ICP",canisterId:"ryjl3-tyaaa-aaaaa-aaaba-cai"}],this.selectedSymbol||(this.selectedSymbol="ICP")}}selectAmount(e){this.selectedAmount=e}selectSymbol(e){this.selectedSymbol=e}get fillPercentage(){let e=Number(this.config?.goalUsd??1e3),t=e>0?e:1e3;return Math.min(this.raised/t*100,100)}async donate(){if(ke&&!this.processing){Y(this.config?.debug||!1,"Donation started",{amount:this.selectedAmount,selectedSymbol:this.selectedSymbol,useOwnWallet:this.config.useOwnWallet}),this.errorMessage=null,this.errorSeverity=null,this.errorAction=null;try{window.dispatchEvent(new CustomEvent("icpay-sdk-method-start",{detail:{name:"donate",type:"sendUsd",amount:this.selectedAmount,currency:this.selectedSymbol}}))}catch{}this.processing=!0;try{if(this.config.useOwnWallet){if(!this.config.actorProvider){this.pendingAction="donate",this.dispatchEvent(new CustomEvent("icpay-connect-wallet",{bubbles:!0}));return}}else if(!this.walletConnected){Y(this.config?.debug||!1,"Connecting to wallet via Plug N Play");try{ae||(ae=(await import("@windoge98/plug-n-play")).PNP),this.pnp=new ae(this.config?.plugNPlay||{});let r=this.pnp.getEnabledWallets();if(Y(this.config?.debug||!1,"Available wallets",r),!r?.length)throw new Error("No wallets available");this.pendingAction="donate",this.showWalletModal=!0;return}catch(r){Y(this.config?.debug||!1,"Wallet connection error:",r),this.errorMessage=r instanceof Error?r.message:"Wallet connection failed",this.errorSeverity="error";return}}Y(this.config?.debug||!1,"Creating SDK for payment");let e=d(this.config),i=this.cryptoOptions.find(r=>r.symbol===this.selectedSymbol).canisterId||await e.client.getLedgerCanisterIdBySymbol(this.selectedSymbol);Y(this.config?.debug||!1,"Donation payment details",{amount:this.selectedAmount,selectedSymbol:this.selectedSymbol,canisterId:i});let o=await e.sendUsd(this.selectedAmount,i,{context:"donation"});Y(this.config?.debug||!1,"Donation payment completed",{resp:o}),this.raised+=this.selectedAmount,this.succeeded=!0,this.config.onSuccess&&this.config.onSuccess({id:o.transactionId,status:o.status,raised:this.raised}),this.dispatchEvent(new CustomEvent("icpay-donation",{detail:{amount:this.selectedAmount,tx:o},bubbles:!0}))}catch(e){S(e,{onError:t=>{this.dispatchEvent(new CustomEvent("icpay-error",{detail:t,bubbles:!0})),W(t)&&(this.errorMessage=k(t),this.errorSeverity=A(t),this.errorAction=L(t))}})}finally{this.processing=!1}}}getWalletId(e){return e&&(e.id||e.provider||e.key)||""}getWalletLabel(e){return e&&(e.label||e.name||e.title||e.id)||"Wallet"}getWalletIcon(e){return e&&(e.icon||e.logo||e.image)||null}async connectWithWallet(e){if(this.pnp)try{if(!e)throw new Error("No wallet ID provided");let t=await this.pnp.connect(e);if(!!!(t&&(t.connected===!0||t.principal||t.owner||this.pnp?.account)))throw new Error("Wallet connection was rejected");this.walletConnected=!0;try{window.dispatchEvent(new CustomEvent("icpay-sdk-wallet-connected",{detail:{walletType:e}}))}catch{}this.config={...this.config,connectedWallet:t,actorProvider:(r,l)=>this.pnp.getActor({canisterId:r,idl:l,requiresSigning:!0,anon:!1})},this.showWalletModal=!1;let o=this.pendingAction;this.pendingAction=null,o==="donate"&&setTimeout(()=>this.donate(),0)}catch(t){this.errorMessage=t instanceof Error?t.message:"Wallet connection failed",this.errorSeverity="error",this.showWalletModal=!1}}render(){return this.config?ne`
772
+ <div class="icpay-card icpay-section" style="text-align:center;">
773
+ ${this.config?.progressBar?.enabled!==!1?ne`<icpay-progress-bar mode="${this.config?.progressBar?.mode||"modal"}"></icpay-progress-bar>`:null}
695
774
  <div class="thermo"><div class="fill" style="height:${this.fillPercentage}%"></div></div>
696
775
  <div class="total">$${Number(this.raised).toFixed(0)} / $${Number(this.config?.goalUsd??0).toFixed(2)}</div>
697
776
 
698
777
  <div class="amounts">
699
- ${this.amounts.map(e=>re`<div class="chip ${this.selectedAmount===e?"selected":""}" @click=${()=>this.selectAmount(e)}>$${e}</div>`)}
778
+ ${this.amounts.map(e=>ne`<div class="chip ${this.selectedAmount===e?"selected":""}" @click=${()=>this.selectAmount(e)}>$${e}</div>`)}
700
779
  </div>
701
780
 
702
781
  <div>
@@ -715,19 +794,19 @@ var Re=Object.defineProperty;var Te=Object.getOwnPropertyDescriptor;var s=(n,a,e
715
794
  ${this.succeeded&&this.config?.disableAfterSuccess?"Donated":this.processing?"Processing\u2026":(this.config?.buttonLabel||"Donate {amount} with {symbol}").replace("{amount}",`${this.selectedAmount}`).replace("{symbol}",this.selectedSymbol)}
716
795
  </button>
717
796
 
718
- ${this.errorMessage?re`
797
+ ${this.errorMessage?ne`
719
798
  <div class="error-message ${this.errorSeverity}" style="margin-top: 12px; padding: 8px 12px; border-radius: 6px; font-size: 14px; text-align: center;">
720
799
  ${this.errorMessage}
721
- ${this.errorAction?re`
800
+ ${this.errorAction?ne`
722
801
  <button style="margin-left: 8px; padding: 4px 8px; background: transparent; border: 1px solid currentColor; border-radius: 4px; font-size: 12px; cursor: pointer;">
723
802
  ${this.errorAction}
724
803
  </button>
725
804
  `:""}
726
805
  </div>
727
806
  `:""}
728
- ${(()=>{let t=(this.pnp?.getEnabledWallets?.()||[]).map(i=>({id:this.getWalletId(i),label:this.getWalletLabel(i),icon:this.getWalletIcon(i)}));return $({visible:!!(this.showWalletModal&&this.pnp),wallets:t,isConnecting:!1,onSelect:i=>this.connectWithWallet(i),onClose:()=>{this.showWalletModal=!1}})})()}
807
+ ${(()=>{let t=(this.pnp?.getEnabledWallets?.()||[]).map(i=>({id:this.getWalletId(i),label:this.getWalletLabel(i),icon:this.getWalletIcon(i)}));return M({visible:!!(this.showWalletModal&&this.pnp),wallets:t,isConnecting:!1,onSelect:i=>this.connectWithWallet(i),onClose:()=>{this.showWalletModal=!1}})})()}
729
808
  </div>
730
- `:re`<div class="card section">Loading...</div>`}};u.styles=[E,ct`
809
+ `:ne`<div class="icpay-card icpay-section">Loading...</div>`}};u.styles=[E,pt`
731
810
  .thermo { width: 60px; height: 200px; background: var(--icpay-surface-alt); border: 3px solid #6b7280; border-radius: 30px; margin: 0 auto 12px; position: relative; overflow: hidden; }
732
811
  .fill { position: absolute; bottom: 0; left: 0; right: 0; background: linear-gradient(135deg, #d1d5db 0%, #9ca3af 100%); transition: height 0.8s ease; height: 0%; border-radius: 0 0 27px 27px; }
733
812
  .amounts { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; margin: 12px 0; }
@@ -759,38 +838,38 @@ var Re=Object.defineProperty;var Te=Object.getOwnPropertyDescriptor;var s=(n,a,e
759
838
  border-color: rgba(239, 68, 68, 0.3);
760
839
  color: #ef4444;
761
840
  }
762
- `],s([pt({type:Object})],u.prototype,"config",2),s([O()],u.prototype,"selectedAmount",2),s([O()],u.prototype,"selectedSymbol",2),s([O()],u.prototype,"raised",2),s([O()],u.prototype,"processing",2),s([O()],u.prototype,"succeeded",2),s([O()],u.prototype,"availableLedgers",2),s([O()],u.prototype,"errorMessage",2),s([O()],u.prototype,"errorSeverity",2),s([O()],u.prototype,"errorAction",2),s([O()],u.prototype,"walletConnected",2),s([O()],u.prototype,"pendingAction",2),s([O()],u.prototype,"showWalletModal",2),u=s([dt("icpay-donation-thermometer")],u);import{LitElement as gt,html as oe,css as ht}from"lit";import{customElement as ut,property as ft,state as B}from"lit/decorators.js";var We=typeof window<"u",Ce=null;function fe(n,a,e){n&&(e!==void 0?console.log(`[ICPay Widget] ${a}`,e):console.log(`[ICPay Widget] ${a}`))}var w=class extends gt{constructor(){super(...arguments);this.selectedSymbol=null;this.processing=!1;this.succeeded=!1;this.availableLedgers=[];this.errorMessage=null;this.errorSeverity=null;this.errorAction=null;this.walletConnected=!1;this.pendingAction=null;this.showWalletModal=!1;this.pnp=null}get cryptoOptions(){return this.config?.cryptoOptions?.length?this.config.cryptoOptions:this.availableLedgers}connectedCallback(){super.connectedCallback(),We&&(fe(this.config?.debug||!1,"Pay button connected",{config:this.config}),this.config?.cryptoOptions&&this.config.cryptoOptions.length>0||this.loadVerifiedLedgers(),this.config?.defaultSymbol&&(this.selectedSymbol=this.config.defaultSymbol))}updated(e){if(e.has("config")&&this.pendingAction&&this.config?.actorProvider){let t=this.pendingAction;this.pendingAction=null;try{window.dispatchEvent(new CustomEvent("icpay-sdk-wallet-connected",{detail:{walletType:"external"}}))}catch{}setTimeout(()=>{t==="pay"&&this.pay()},0)}}async loadVerifiedLedgers(){if(!(!We||!this.config?.publishableKey))try{let t=await d(this.config).client.getVerifiedLedgers();this.availableLedgers=t.map(i=>({symbol:i.symbol,label:i.name,canisterId:i.canisterId})),this.selectedSymbol||(this.selectedSymbol=this.config?.defaultSymbol||(this.availableLedgers[0]?.symbol??"ICP"))}catch(e){this.dispatchEvent(new CustomEvent("icpay-error",{detail:{message:"Failed to load verified ledgers",cause:e},bubbles:!0})),this.availableLedgers=[{symbol:"ICP",label:"ICP",canisterId:"ryjl3-tyaaa-aaaaa-aaaba-cai"}],this.selectedSymbol||(this.selectedSymbol=this.config?.defaultSymbol||"ICP")}}selectSymbol(e){this.selectedSymbol=e}async ensureWallet(){if(this.config.useOwnWallet)return this.config.actorProvider?!0:(this.pendingAction="pay",this.dispatchEvent(new CustomEvent("icpay-connect-wallet",{bubbles:!0})),!1);if(this.walletConnected)return!0;try{Ce||(Ce=(await import("@windoge98/plug-n-play")).PNP),this.pnp=new Ce(this.config?.plugNPlay||{});let e=this.pnp.getEnabledWallets();if(fe(this.config?.debug||!1,"Available wallets",e),!e?.length)throw new Error("No wallets available");return this.pendingAction="pay",this.showWalletModal=!0,!1}catch(e){return this.errorMessage=e instanceof Error?e.message:"Wallet connection failed",this.errorSeverity="error",!1}}getWalletId(e){return e&&(e.id||e.provider||e.key)||""}getWalletLabel(e){return e&&(e.label||e.name||e.title||e.id)||"Wallet"}getWalletIcon(e){return e&&(e.icon||e.logo||e.image)||null}async connectWithWallet(e){if(this.pnp)try{if(fe(this.config?.debug||!1,"Connecting to wallet",{walletId:e}),!e)throw new Error("No wallet ID provided");let t=await this.pnp.connect(e);if(fe(this.config?.debug||!1,"Wallet connect result",t),!!!(t&&(t.connected===!0||t.principal||t.owner||this.pnp?.account)))throw new Error("Wallet connection was rejected");this.walletConnected=!0;try{window.dispatchEvent(new CustomEvent("icpay-sdk-wallet-connected",{detail:{walletType:e}}))}catch{}this.config={...this.config,connectedWallet:t,actorProvider:(o,l)=>this.pnp.getActor({canisterId:o,idl:l,requiresSigning:!0,anon:!1})},this.showWalletModal=!1;let r=this.pendingAction;this.pendingAction=null,r==="pay"&&setTimeout(()=>this.pay(),0)}catch(t){fe(this.config?.debug||!1,"Wallet connection error",t),this.errorMessage=t instanceof Error?t.message:"Wallet connection failed",this.errorSeverity="error",this.showWalletModal=!1}}renderWalletModal(){if(!this.showWalletModal||!this.pnp)return null;let t=(this.pnp.getEnabledWallets()||[]).map(i=>({id:this.getWalletId(i),label:this.getWalletLabel(i),icon:this.getWalletIcon(i)}));return $({visible:this.showWalletModal,wallets:t,isConnecting:!1,onSelect:i=>this.connectWithWallet(i),onClose:()=>{this.showWalletModal=!1}})}async pay(){if(!(!We||this.processing)){this.errorMessage=null,this.errorSeverity=null,this.errorAction=null;try{window.dispatchEvent(new CustomEvent("icpay-sdk-method-start",{detail:{name:"pay",type:"sendUsd",amount:this.config?.amountUsd,currency:this.selectedSymbol||this.config?.defaultSymbol}}))}catch{}this.processing=!0;try{if(!await this.ensureWallet())return;let t=d(this.config),i=this.selectedSymbol||"ICP",o=this.cryptoOptions.find(A=>A.symbol===i)?.canisterId||await t.client.getLedgerCanisterIdBySymbol(i),l=Number(this.config?.amountUsd??0),c={context:"pay-button"},b=await t.sendUsd(l,o,c);this.config.onSuccess&&this.config.onSuccess({id:b.transactionId,status:b.status}),this.succeeded=!0,this.dispatchEvent(new CustomEvent("icpay-pay",{detail:{amount:l,tx:b},bubbles:!0}))}catch(e){S(e,{onError:t=>{this.dispatchEvent(new CustomEvent("icpay-error",{detail:t,bubbles:!0})),W(t)&&(this.errorMessage=k(t),this.errorSeverity=L(t),this.errorAction=C(t))}})}finally{this.processing=!1}}}render(){if(!this.config)return oe`<div class="card section">Loading...</div>`;let t=(this.cryptoOptions?.length||0)>1,i=this.config?.showLedgerDropdown,r=i==="dropdown"?"dropdown":i==="none"?"none":"buttons",o=r!=="none"&&(t||r==="dropdown"),l=r==="dropdown"?"dropdown":t?"buttons":"none",c=this.selectedSymbol||this.config?.defaultSymbol||"ICP",b=typeof this.config?.amountUsd=="number"?`${Number(this.config.amountUsd).toFixed(2)}`:"",ae=(this.config?.buttonLabel||(typeof this.config?.amountUsd=="number"?"Pay ${amount} with {symbol}":"Pay with {symbol}")).replace("{amount}",b||"$0.00").replace("{symbol}",c),le=this.config?.progressBar?.enabled!==!1;return oe`
763
- <div class="card section">
764
- ${le?oe`
841
+ `],s([ht({type:Object})],u.prototype,"config",2),s([N()],u.prototype,"selectedAmount",2),s([N()],u.prototype,"selectedSymbol",2),s([N()],u.prototype,"raised",2),s([N()],u.prototype,"processing",2),s([N()],u.prototype,"succeeded",2),s([N()],u.prototype,"availableLedgers",2),s([N()],u.prototype,"errorMessage",2),s([N()],u.prototype,"errorSeverity",2),s([N()],u.prototype,"errorAction",2),s([N()],u.prototype,"walletConnected",2),s([N()],u.prototype,"pendingAction",2),s([N()],u.prototype,"showWalletModal",2),u=s([gt("icpay-donation-thermometer")],u);import{LitElement as ut,html as le,css as ft}from"lit";import{customElement as yt,property as bt,state as z}from"lit/decorators.js";var We=typeof window<"u",Le=null;function fe(n,a,e){n&&(e!==void 0?console.log(`[ICPay Widget] ${a}`,e):console.log(`[ICPay Widget] ${a}`))}var w=class extends ut{constructor(){super(...arguments);this.selectedSymbol=null;this.processing=!1;this.succeeded=!1;this.availableLedgers=[];this.errorMessage=null;this.errorSeverity=null;this.errorAction=null;this.walletConnected=!1;this.pendingAction=null;this.showWalletModal=!1;this.pnp=null}get cryptoOptions(){return this.config?.cryptoOptions?.length?this.config.cryptoOptions:this.availableLedgers}connectedCallback(){super.connectedCallback(),We&&(fe(this.config?.debug||!1,"Pay button connected",{config:this.config}),this.config?.cryptoOptions&&this.config.cryptoOptions.length>0||this.loadVerifiedLedgers(),this.config?.defaultSymbol&&(this.selectedSymbol=this.config.defaultSymbol))}updated(e){if(e.has("config")&&this.pendingAction&&this.config?.actorProvider){let t=this.pendingAction;this.pendingAction=null;try{window.dispatchEvent(new CustomEvent("icpay-sdk-wallet-connected",{detail:{walletType:"external"}}))}catch{}setTimeout(()=>{t==="pay"&&this.pay()},0)}}async loadVerifiedLedgers(){if(!(!We||!this.config?.publishableKey))try{let t=await d(this.config).client.getVerifiedLedgers();this.availableLedgers=t.map(i=>({symbol:i.symbol,label:i.name,canisterId:i.canisterId})),this.selectedSymbol||(this.selectedSymbol=this.config?.defaultSymbol||(this.availableLedgers[0]?.symbol??"ICP"))}catch(e){this.dispatchEvent(new CustomEvent("icpay-error",{detail:{message:"Failed to load verified ledgers",cause:e},bubbles:!0})),this.availableLedgers=[{symbol:"ICP",label:"ICP",canisterId:"ryjl3-tyaaa-aaaaa-aaaba-cai"}],this.selectedSymbol||(this.selectedSymbol=this.config?.defaultSymbol||"ICP")}}selectSymbol(e){this.selectedSymbol=e}async ensureWallet(){if(this.config.useOwnWallet)return this.config.actorProvider?!0:(this.pendingAction="pay",this.dispatchEvent(new CustomEvent("icpay-connect-wallet",{bubbles:!0})),!1);if(this.walletConnected)return!0;try{Le||(Le=(await import("@windoge98/plug-n-play")).PNP),this.pnp=new Le(this.config?.plugNPlay||{});let e=this.pnp.getEnabledWallets();if(fe(this.config?.debug||!1,"Available wallets",e),!e?.length)throw new Error("No wallets available");return this.pendingAction="pay",this.showWalletModal=!0,!1}catch(e){return this.errorMessage=e instanceof Error?e.message:"Wallet connection failed",this.errorSeverity="error",!1}}getWalletId(e){return e&&(e.id||e.provider||e.key)||""}getWalletLabel(e){return e&&(e.label||e.name||e.title||e.id)||"Wallet"}getWalletIcon(e){return e&&(e.icon||e.logo||e.image)||null}async connectWithWallet(e){if(this.pnp)try{if(fe(this.config?.debug||!1,"Connecting to wallet",{walletId:e}),!e)throw new Error("No wallet ID provided");let t=await this.pnp.connect(e);if(fe(this.config?.debug||!1,"Wallet connect result",t),!!!(t&&(t.connected===!0||t.principal||t.owner||this.pnp?.account)))throw new Error("Wallet connection was rejected");this.walletConnected=!0;try{window.dispatchEvent(new CustomEvent("icpay-sdk-wallet-connected",{detail:{walletType:e}}))}catch{}this.config={...this.config,connectedWallet:t,actorProvider:(r,l)=>this.pnp.getActor({canisterId:r,idl:l,requiresSigning:!0,anon:!1})},this.showWalletModal=!1;let o=this.pendingAction;this.pendingAction=null,o==="pay"&&setTimeout(()=>this.pay(),0)}catch(t){fe(this.config?.debug||!1,"Wallet connection error",t),this.errorMessage=t instanceof Error?t.message:"Wallet connection failed",this.errorSeverity="error",this.showWalletModal=!1}}renderWalletModal(){if(!this.showWalletModal||!this.pnp)return null;let t=(this.pnp.getEnabledWallets()||[]).map(i=>({id:this.getWalletId(i),label:this.getWalletLabel(i),icon:this.getWalletIcon(i)}));return M({visible:this.showWalletModal,wallets:t,isConnecting:!1,onSelect:i=>this.connectWithWallet(i),onClose:()=>{this.showWalletModal=!1}})}async pay(){if(!(!We||this.processing)){this.errorMessage=null,this.errorSeverity=null,this.errorAction=null;try{window.dispatchEvent(new CustomEvent("icpay-sdk-method-start",{detail:{name:"pay",type:"sendUsd",amount:this.config?.amountUsd,currency:this.selectedSymbol||this.config?.defaultSymbol}}))}catch{}this.processing=!0;try{if(!await this.ensureWallet())return;let t=d(this.config),i=this.selectedSymbol||"ICP",r=this.cryptoOptions.find(O=>O.symbol===i)?.canisterId||await t.client.getLedgerCanisterIdBySymbol(i),l=Number(this.config?.amountUsd??0),c={context:"pay-button"},m=await t.sendUsd(l,r,c);this.config.onSuccess&&this.config.onSuccess({id:m.transactionId,status:m.status}),this.succeeded=!0,this.dispatchEvent(new CustomEvent("icpay-pay",{detail:{amount:l,tx:m},bubbles:!0}))}catch(e){S(e,{onError:t=>{this.dispatchEvent(new CustomEvent("icpay-error",{detail:t,bubbles:!0})),W(t)&&(this.errorMessage=k(t),this.errorSeverity=A(t),this.errorAction=L(t))}})}finally{this.processing=!1}}}render(){if(!this.config)return le`<div class="icpay-card icpay-section">Loading...</div>`;let t=(this.cryptoOptions?.length||0)>1,i=this.config?.showLedgerDropdown,o=i==="dropdown"?"dropdown":i==="none"?"none":"buttons",r=o!=="none"&&(t||o==="dropdown"),l=o==="dropdown"?"dropdown":t?"buttons":"none",c=this.selectedSymbol||this.config?.defaultSymbol||"ICP",m=typeof this.config?.amountUsd=="number"?`${Number(this.config.amountUsd).toFixed(2)}`:"",ce=(this.config?.buttonLabel||(typeof this.config?.amountUsd=="number"?"Pay ${amount} with {symbol}":"Pay with {symbol}")).replace("{amount}",m||"$0.00").replace("{symbol}",c),de=this.config?.progressBar?.enabled!==!1;return le`
842
+ <div class="icpay-card icpay-section">
843
+ ${de?le`
765
844
  <icpay-progress-bar></icpay-progress-bar>
766
845
  `:null}
767
846
 
768
- <div class="row ${o?"":"single"}">
769
- ${o?oe`
847
+ <div class="row ${r?"":"single"}">
848
+ ${r?le`
770
849
  <icpay-token-selector
771
850
  .options=${this.cryptoOptions}
772
851
  .value=${this.selectedSymbol||""}
773
852
  .defaultSymbol=${this.config?.defaultSymbol||"ICP"}
774
853
  mode=${l}
775
- @icpay-token-change=${F=>this.selectSymbol(F.detail.symbol)}
854
+ @icpay-token-change=${K=>this.selectSymbol(K.detail.symbol)}
776
855
  ></icpay-token-selector>
777
856
  `:null}
778
857
  <button class="pay-button ${this.processing?"processing":""}"
779
858
  ?disabled=${this.processing||this.config?.disablePaymentButton===!0||this.succeeded&&this.config?.disableAfterSuccess===!0}
780
859
  @click=${()=>this.pay()}>
781
- ${this.succeeded&&this.config?.disableAfterSuccess?"Paid":this.processing?"Processing\u2026":ae}
860
+ ${this.succeeded&&this.config?.disableAfterSuccess?"Paid":this.processing?"Processing\u2026":ce}
782
861
  </button>
783
862
  </div>
784
863
 
785
- ${this.errorMessage?oe`
864
+ ${this.errorMessage?le`
786
865
  <div class="error-message ${this.errorSeverity}" style="margin-top: 12px; padding: 8px 12px; border-radius: 6px; font-size: 14px; text-align: center;">
787
866
  ${this.errorMessage}
788
- ${this.errorAction?oe`<button style="margin-left: 8px; padding: 4px 8px; background: transparent; border: 1px solid currentColor; border-radius: 4px; font-size: 12px; cursor: pointer;">${this.errorAction}</button>`:""}
867
+ ${this.errorAction?le`<button style="margin-left: 8px; padding: 4px 8px; background: transparent; border: 1px solid currentColor; border-radius: 4px; font-size: 12px; cursor: pointer;">${this.errorAction}</button>`:""}
789
868
  </div>
790
869
  `:""}
791
870
  ${this.renderWalletModal()}
792
871
  </div>
793
- `}};w.styles=[E,ht`
872
+ `}};w.styles=[E,ft`
794
873
  .row { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; }
795
874
  .row.single { grid-template-columns: 1fr; }
796
875
  select { background: var(--icpay-surface-alt); border: 1px solid var(--icpay-border); color: var(--icpay-text); border-radius: 8px; padding: 10px; font-weight: 600; }
@@ -798,23 +877,29 @@ var Re=Object.defineProperty;var Te=Object.getOwnPropertyDescriptor;var s=(n,a,e
798
877
  .error-message.info { background: rgba(59,130,246,0.1); border-color: rgba(59,130,246,0.3); color: #3b82f6; }
799
878
  .error-message.warning { background: rgba(245,158,11,0.1); border-color: rgba(245,158,11,0.3); color: #f59e0b; }
800
879
  .error-message.error { background: rgba(239,68,68,0.1); border-color: rgba(239,68,68,0.3); color: #ef4444; }
801
- `],s([ft({type:Object})],w.prototype,"config",2),s([B()],w.prototype,"selectedSymbol",2),s([B()],w.prototype,"processing",2),s([B()],w.prototype,"succeeded",2),s([B()],w.prototype,"availableLedgers",2),s([B()],w.prototype,"errorMessage",2),s([B()],w.prototype,"errorSeverity",2),s([B()],w.prototype,"errorAction",2),s([B()],w.prototype,"walletConnected",2),s([B()],w.prototype,"pendingAction",2),s([B()],w.prototype,"showWalletModal",2),w=s([ut("icpay-pay-button")],w);import{LitElement as yt,html as G,css as mt}from"lit";import{customElement as bt,property as vt,state as I}from"lit/decorators.js";var Le=typeof window<"u",$e=null;function wt(n,a,e){n&&(e!==void 0?console.log(`[ICPay Widget] ${a}`,e):console.log(`[ICPay Widget] ${a}`))}var f=class extends yt{constructor(){super(...arguments);this.amountUsd=0;this.hasUserAmount=!1;this.selectedSymbol=null;this.processing=!1;this.succeeded=!1;this.availableLedgers=[];this.errorMessage=null;this.errorSeverity=null;this.errorAction=null;this.walletConnected=!1;this.pendingAction=null;this.showWalletModal=!1;this.pnp=null}get cryptoOptions(){return this.config?.cryptoOptions?.length?this.config.cryptoOptions:this.availableLedgers}connectedCallback(){super.connectedCallback(),Le&&(wt(this.config?.debug||!1,"Amount input connected",{config:this.config}),this.amountUsd=Number(this.config?.defaultAmountUsd??0),this.hasUserAmount=!1,this.config?.cryptoOptions&&this.config.cryptoOptions.length>0||this.loadVerifiedLedgers(),this.config?.defaultSymbol&&(this.selectedSymbol=this.config.defaultSymbol))}updated(e){if(e.has("config")&&(!this.hasUserAmount&&typeof this.config?.defaultAmountUsd=="number"&&(this.amountUsd===0||this.amountUsd==null||Number.isNaN(this.amountUsd))&&(this.amountUsd=Number(this.config.defaultAmountUsd)),!this.selectedSymbol&&this.config?.defaultSymbol&&(this.selectedSymbol=this.config.defaultSymbol),!(this.config?.cryptoOptions&&this.config.cryptoOptions.length>0)&&this.availableLedgers.length===0&&this.loadVerifiedLedgers(),this.pendingAction&&this.config?.actorProvider)){let t=this.pendingAction;this.pendingAction=null;try{window.dispatchEvent(new CustomEvent("icpay-sdk-wallet-connected",{detail:{walletType:"external"}}))}catch{}setTimeout(()=>{t==="pay"&&this.pay()},0)}}async loadVerifiedLedgers(){if(!(!Le||!this.config?.publishableKey))try{let t=await d(this.config).client.getVerifiedLedgers();this.availableLedgers=t.map(i=>({symbol:i.symbol,label:i.name,canisterId:i.canisterId})),this.selectedSymbol||(this.selectedSymbol=this.config?.defaultSymbol||(this.availableLedgers[0]?.symbol??"ICP"))}catch(e){this.dispatchEvent(new CustomEvent("icpay-error",{detail:{message:"Failed to load verified ledgers",cause:e},bubbles:!0})),this.availableLedgers=[{symbol:"ICP",label:"ICP",canisterId:"ryjl3-tyaaa-aaaaa-aaaba-cai"}],this.selectedSymbol||(this.selectedSymbol=this.config?.defaultSymbol||"ICP")}}onInputChange(e){let t=Number(this.config?.stepUsd??.5),i=Math.max(0,Number(e.target.value||0)),r=Math.round(i/t)*t;this.amountUsd=Number(r.toFixed(2)),this.hasUserAmount=!0}selectSymbol(e){this.selectedSymbol=e}isValidAmount(){let e=Number(this.config?.minUsd??.5),t=this.config?.maxUsd!==void 0?Number(this.config.maxUsd):1/0;return this.amountUsd>=e&&this.amountUsd<=t}async ensureWallet(){if(this.config.useOwnWallet)return this.config.actorProvider?!0:(this.pendingAction="pay",this.dispatchEvent(new CustomEvent("icpay-connect-wallet",{bubbles:!0})),!1);if(this.walletConnected)return!0;try{if($e||($e=(await import("@windoge98/plug-n-play")).PNP),this.pnp=new $e(this.config?.plugNPlay||{}),!this.pnp.getEnabledWallets()?.length)throw new Error("No wallets available");return this.pendingAction="pay",this.showWalletModal=!0,!1}catch(e){return this.errorMessage=e instanceof Error?e.message:"Wallet connection failed",this.errorSeverity="error",!1}}getWalletId(e){return e&&(e.id||e.provider||e.key)||""}getWalletLabel(e){return e&&(e.label||e.name||e.title||e.id)||"Wallet"}getWalletIcon(e){return e&&(e.icon||e.logo||e.image)||null}async connectWithWallet(e){if(this.pnp)try{if(!e)throw new Error("No wallet ID provided");let t=await this.pnp.connect(e);if(!!!(t&&(t.connected===!0||t.principal||t.owner||this.pnp?.account)))throw new Error("Wallet connection was rejected");this.walletConnected=!0;try{window.dispatchEvent(new CustomEvent("icpay-sdk-wallet-connected",{detail:{walletType:e}}))}catch{}this.config={...this.config,connectedWallet:t,actorProvider:(o,l)=>this.pnp.getActor({canisterId:o,idl:l,requiresSigning:!0,anon:!1})},this.showWalletModal=!1;let r=this.pendingAction;this.pendingAction=null,r==="pay"&&setTimeout(()=>this.pay(),0)}catch(t){this.errorMessage=t instanceof Error?t.message:"Wallet connection failed",this.errorSeverity="error",this.showWalletModal=!1}}async pay(){if(!(!Le||this.processing)){if(this.errorMessage=null,this.errorSeverity=null,this.errorAction=null,!this.isValidAmount()){this.errorMessage="Please enter a valid amount",this.errorSeverity="warning";return}try{window.dispatchEvent(new CustomEvent("icpay-sdk-method-start",{detail:{name:"pay",type:"sendUsd",amount:this.amountUsd,currency:this.selectedSymbol||this.config?.defaultSymbol}}))}catch{}this.processing=!0;try{if(!await this.ensureWallet())return;let t=d(this.config),i=this.selectedSymbol||"ICP",o=this.cryptoOptions.find(A=>A.symbol===i)?.canisterId||await t.client.getLedgerCanisterIdBySymbol(i),l=Number(this.amountUsd),c={context:"amount-input"},b=await t.sendUsd(l,o,c);this.config.onSuccess&&this.config.onSuccess({id:b.transactionId,status:b.status,amountUsd:l}),this.succeeded=!0,this.dispatchEvent(new CustomEvent("icpay-amount-pay",{detail:{amount:l,tx:b},bubbles:!0}))}catch(e){S(e,{onError:t=>{this.dispatchEvent(new CustomEvent("icpay-error",{detail:t,bubbles:!0})),W(t)&&(this.errorMessage=k(t),this.errorSeverity=L(t),this.errorAction=C(t))}})}finally{this.processing=!1}}}render(){if(!this.config)return G`<div class="card section">Loading...</div>`;let e=this.config?.placeholder||"Enter amount in USD",i=(this.config?.buttonLabel||"Pay ${amount} with {symbol}").replace("{amount}",this.amountUsd?`${Number(this.amountUsd).toFixed(2)}`:"$0.00").replace("{symbol}",this.selectedSymbol||this.config?.defaultSymbol||"ICP"),r=this.config?.showLedgerDropdown===!0,o=this.cryptoOptions.find(D=>D.symbol===(this.selectedSymbol||""))?.label||this.cryptoOptions[0]?.label||this.config?.defaultSymbol||"ICP",l=this.config?.progressBar?.mode||"modal",c=this.config?.showLedgerDropdown,b=c==="buttons"?"buttons":c==="none"?"none":"dropdown",ae=this.config?.progressBar?.enabled!==!1&&(l==="modal"?!0:this.processing);return G`
802
- <div class="card section">
803
- ${ae?G`<icpay-progress-bar mode="${l}"></icpay-progress-bar>`:null}
880
+ `],s([bt({type:Object})],w.prototype,"config",2),s([z()],w.prototype,"selectedSymbol",2),s([z()],w.prototype,"processing",2),s([z()],w.prototype,"succeeded",2),s([z()],w.prototype,"availableLedgers",2),s([z()],w.prototype,"errorMessage",2),s([z()],w.prototype,"errorSeverity",2),s([z()],w.prototype,"errorAction",2),s([z()],w.prototype,"walletConnected",2),s([z()],w.prototype,"pendingAction",2),s([z()],w.prototype,"showWalletModal",2),w=s([yt("icpay-pay-button")],w);import{LitElement as mt,html as X,css as vt}from"lit";import{customElement as wt,property as xt,state as T}from"lit/decorators.js";var Ae=typeof window<"u",Ce=null;function Et(n,a,e){n&&(e!==void 0?console.log(`[ICPay Widget] ${a}`,e):console.log(`[ICPay Widget] ${a}`))}var f=class extends mt{constructor(){super(...arguments);this.amountUsd=0;this.hasUserAmount=!1;this.selectedSymbol=null;this.processing=!1;this.succeeded=!1;this.availableLedgers=[];this.errorMessage=null;this.errorSeverity=null;this.errorAction=null;this.walletConnected=!1;this.pendingAction=null;this.showWalletModal=!1;this.pnp=null}get cryptoOptions(){return this.config?.cryptoOptions?.length?this.config.cryptoOptions:this.availableLedgers}connectedCallback(){super.connectedCallback(),Ae&&(Et(this.config?.debug||!1,"Amount input connected",{config:this.config}),this.amountUsd=Number(this.config?.defaultAmountUsd??0),this.hasUserAmount=!1,this.config?.cryptoOptions&&this.config.cryptoOptions.length>0||this.loadVerifiedLedgers(),this.config?.defaultSymbol&&(this.selectedSymbol=this.config.defaultSymbol))}updated(e){if(e.has("config")&&(!this.hasUserAmount&&typeof this.config?.defaultAmountUsd=="number"&&(this.amountUsd===0||this.amountUsd==null||Number.isNaN(this.amountUsd))&&(this.amountUsd=Number(this.config.defaultAmountUsd)),!this.selectedSymbol&&this.config?.defaultSymbol&&(this.selectedSymbol=this.config.defaultSymbol),!(this.config?.cryptoOptions&&this.config.cryptoOptions.length>0)&&this.availableLedgers.length===0&&this.loadVerifiedLedgers(),this.pendingAction&&this.config?.actorProvider)){let t=this.pendingAction;this.pendingAction=null;try{window.dispatchEvent(new CustomEvent("icpay-sdk-wallet-connected",{detail:{walletType:"external"}}))}catch{}setTimeout(()=>{t==="pay"&&this.pay()},0)}}async loadVerifiedLedgers(){if(!(!Ae||!this.config?.publishableKey))try{let t=await d(this.config).client.getVerifiedLedgers();this.availableLedgers=t.map(i=>({symbol:i.symbol,label:i.name,canisterId:i.canisterId})),this.selectedSymbol||(this.selectedSymbol=this.config?.defaultSymbol||(this.availableLedgers[0]?.symbol??"ICP"))}catch(e){this.dispatchEvent(new CustomEvent("icpay-error",{detail:{message:"Failed to load verified ledgers",cause:e},bubbles:!0})),this.availableLedgers=[{symbol:"ICP",label:"ICP",canisterId:"ryjl3-tyaaa-aaaaa-aaaba-cai"}],this.selectedSymbol||(this.selectedSymbol=this.config?.defaultSymbol||"ICP")}}onInputChange(e){let t=Number(this.config?.stepUsd??.5),i=Math.max(0,Number(e.target.value||0)),o=Math.round(i/t)*t;this.amountUsd=Number(o.toFixed(2)),this.hasUserAmount=!0}selectSymbol(e){this.selectedSymbol=e}isValidAmount(){let e=Number(this.config?.minUsd??.5),t=this.config?.maxUsd!==void 0?Number(this.config.maxUsd):1/0;return this.amountUsd>=e&&this.amountUsd<=t}async ensureWallet(){if(this.config.useOwnWallet)return this.config.actorProvider?!0:(this.pendingAction="pay",this.dispatchEvent(new CustomEvent("icpay-connect-wallet",{bubbles:!0})),!1);if(this.walletConnected)return!0;try{if(Ce||(Ce=(await import("@windoge98/plug-n-play")).PNP),this.pnp=new Ce(this.config?.plugNPlay||{}),!this.pnp.getEnabledWallets()?.length)throw new Error("No wallets available");return this.pendingAction="pay",this.showWalletModal=!0,!1}catch(e){return this.errorMessage=e instanceof Error?e.message:"Wallet connection failed",this.errorSeverity="error",!1}}getWalletId(e){return e&&(e.id||e.provider||e.key)||""}getWalletLabel(e){return e&&(e.label||e.name||e.title||e.id)||"Wallet"}getWalletIcon(e){return e&&(e.icon||e.logo||e.image)||null}async connectWithWallet(e){if(this.pnp)try{if(!e)throw new Error("No wallet ID provided");let t=await this.pnp.connect(e);if(!!!(t&&(t.connected===!0||t.principal||t.owner||this.pnp?.account)))throw new Error("Wallet connection was rejected");this.walletConnected=!0;try{window.dispatchEvent(new CustomEvent("icpay-sdk-wallet-connected",{detail:{walletType:e}}))}catch{}this.config={...this.config,connectedWallet:t,actorProvider:(r,l)=>this.pnp.getActor({canisterId:r,idl:l,requiresSigning:!0,anon:!1})},this.showWalletModal=!1;let o=this.pendingAction;this.pendingAction=null,o==="pay"&&setTimeout(()=>this.pay(),0)}catch(t){this.errorMessage=t instanceof Error?t.message:"Wallet connection failed",this.errorSeverity="error",this.showWalletModal=!1}}async pay(){if(!(!Ae||this.processing)){if(this.errorMessage=null,this.errorSeverity=null,this.errorAction=null,!this.isValidAmount()){this.errorMessage="Please enter a valid amount",this.errorSeverity="warning";return}try{window.dispatchEvent(new CustomEvent("icpay-sdk-method-start",{detail:{name:"pay",type:"sendUsd",amount:this.amountUsd,currency:this.selectedSymbol||this.config?.defaultSymbol}}))}catch{}this.processing=!0;try{if(!await this.ensureWallet())return;let t=d(this.config),i=this.selectedSymbol||"ICP",r=this.cryptoOptions.find(O=>O.symbol===i)?.canisterId||await t.client.getLedgerCanisterIdBySymbol(i),l=Number(this.amountUsd),c={context:"amount-input"},m=await t.sendUsd(l,r,c);this.config.onSuccess&&this.config.onSuccess({id:m.transactionId,status:m.status,amountUsd:l}),this.succeeded=!0,this.dispatchEvent(new CustomEvent("icpay-amount-pay",{detail:{amount:l,tx:m},bubbles:!0}))}catch(e){S(e,{onError:t=>{this.dispatchEvent(new CustomEvent("icpay-error",{detail:t,bubbles:!0})),W(t)&&(this.errorMessage=k(t),this.errorSeverity=A(t),this.errorAction=L(t))}})}finally{this.processing=!1}}}render(){if(!this.config)return X`<div class="icpay-card icpay-section">Loading...</div>`;let e=this.config?.placeholder||"Enter amount in USD",i=(this.config?.buttonLabel||"Pay ${amount} with {symbol}").replace("{amount}",this.amountUsd?`${Number(this.amountUsd).toFixed(2)}`:"$0.00").replace("{symbol}",this.selectedSymbol||this.config?.defaultSymbol||"ICP"),o=this.config?.showLedgerDropdown===!0,r=this.cryptoOptions.find(B=>B.symbol===(this.selectedSymbol||""))?.label||this.cryptoOptions[0]?.label||this.config?.defaultSymbol||"ICP",l=this.config?.progressBar?.mode||"modal",c=this.config?.showLedgerDropdown,m=c==="buttons"?"buttons":c==="none"?"none":"dropdown",ce=this.config?.progressBar?.enabled!==!1&&(l==="modal"?!0:this.processing);return X`
881
+ <div class="icpay-card icpay-section">
882
+ ${ce?X`<icpay-progress-bar mode="${l}"></icpay-progress-bar>`:null}
804
883
 
805
884
  <div class="row">
806
- <input type="number" min="0" step="${Number(this.config?.stepUsd??.5)}" .value=${String(this.amountUsd||"")} placeholder="${e}" @input=${D=>this.onInputChange(D)} />
807
- ${b!=="none"?G`
808
- <icpay-token-selector
809
- .options=${this.cryptoOptions}
810
- .value=${this.selectedSymbol||""}
811
- .defaultSymbol=${this.config?.defaultSymbol||"ICP"}
812
- mode=${b}
813
- @icpay-token-change=${D=>this.selectSymbol(D.detail.symbol)}
814
- ></icpay-token-selector>
815
- `:G`
816
- <div class="label" style="padding: 10px;">${o}</div>
817
- `}
885
+ <div class="top-row">
886
+ <div class="amount-field">
887
+ <span class="currency-prefix">$</span>
888
+ <input type="number" min="0" step="${Number(this.config?.stepUsd??.5)}" .value=${String(this.amountUsd||"")} placeholder="${e}" @input=${B=>this.onInputChange(B)} />
889
+ </div>
890
+ ${m!=="none"?X`
891
+ <icpay-token-selector
892
+ .options=${this.cryptoOptions}
893
+ .value=${this.selectedSymbol||""}
894
+ .defaultSymbol=${this.config?.defaultSymbol||"ICP"}
895
+ mode=${m}
896
+ .showLabel=${!1}
897
+ @icpay-token-change=${B=>this.selectSymbol(B.detail.symbol)}
898
+ ></icpay-token-selector>
899
+ `:X`
900
+ <div class="label" style="padding: 10px;">${r}</div>
901
+ `}
902
+ </div>
818
903
  <button class="pay-button ${this.processing?"processing":""}"
819
904
  ?disabled=${this.processing||this.config?.disablePaymentButton===!0||this.succeeded&&this.config?.disableAfterSuccess===!0}
820
905
  @click=${()=>this.pay()}>
@@ -823,22 +908,32 @@ var Re=Object.defineProperty;var Te=Object.getOwnPropertyDescriptor;var s=(n,a,e
823
908
  </div>
824
909
  <div class="hint">Default: ${this.config?.defaultSymbol||"ICP"}. Min: $${Number(this.config?.minUsd??.5).toFixed(2)}${this.config?.maxUsd?`, Max: $${Number(this.config.maxUsd).toFixed(2)}`:""}</div>
825
910
 
826
- ${this.errorMessage?G`
911
+ ${this.errorMessage?X`
827
912
  <div class="error-message ${this.errorSeverity}" style="margin-top: 12px; padding: 8px 12px; border-radius: 6px; font-size: 14px; text-align: center;">
828
913
  ${this.errorMessage}
829
- ${this.errorAction?G`<button style="margin-left: 8px; padding: 4px 8px; background: transparent; border: 1px solid currentColor; border-radius: 4px; font-size: 12px; cursor: pointer;">${this.errorAction}</button>`:""}
914
+ ${this.errorAction?X`<button style="margin-left: 8px; padding: 4px 8px; background: transparent; border: 1px solid currentColor; border-radius: 4px; font-size: 12px; cursor: pointer;">${this.errorAction}</button>`:""}
830
915
  </div>
831
916
  `:""}
832
- ${(()=>{let le=(this.pnp?.getEnabledWallets?.()||[]).map(F=>({id:this.getWalletId(F),label:this.getWalletLabel(F),icon:this.getWalletIcon(F)}));return $({visible:!!(this.showWalletModal&&this.pnp),wallets:le,isConnecting:!1,onSelect:F=>this.connectWithWallet(F),onClose:()=>{this.showWalletModal=!1}})})()}
917
+ ${(()=>{let de=(this.pnp?.getEnabledWallets?.()||[]).map(K=>({id:this.getWalletId(K),label:this.getWalletLabel(K),icon:this.getWalletIcon(K)}));return M({visible:!!(this.showWalletModal&&this.pnp),wallets:de,isConnecting:!1,onSelect:K=>this.connectWithWallet(K),onClose:()=>{this.showWalletModal=!1}})})()}
833
918
  </div>
834
- `}};f.styles=[E,mt`
835
- .row { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: center; }
836
- input[type="number"] { background: var(--icpay-surface-alt); border: 1px solid var(--icpay-border); color: var(--icpay-text); border-radius: 8px; padding: 10px; font-weight: 600; }
919
+ `}};f.styles=[E,vt`
920
+ .row { display: grid; grid-template-columns: 1fr; gap: 12px; align-items: stretch; }
921
+ .top-row { display: grid; grid-template-columns: 1fr 2fr; gap: 10px; align-items: center; }
922
+ icpay-token-selector { width: 100%; }
923
+ .amount-field { position: relative; width: 100%; }
924
+ .amount-field .currency-prefix { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--icpay-muted, #a3a3a3); font-weight: 600; pointer-events: none; z-index: 2; }
925
+ .amount-field input[type="number"] { padding-left: 32px; position: relative; z-index: 1; }
926
+ input[type="number"] { background: var(--icpay-surface-alt); border: 1px solid var(--icpay-border); color: var(--icpay-text); border-radius: 8px; padding: 10px; font-weight: 600; width: 100%; box-sizing: border-box; height: 54px; }
837
927
  select { background: var(--icpay-surface-alt); border: 1px solid var(--icpay-border); color: var(--icpay-text); border-radius: 8px; padding: 10px; font-weight: 600; }
928
+ .pay-button { width: 100%; }
838
929
  .error-message { border: 1px solid; font-weight: 500; }
839
930
  .error-message.info { background: rgba(59,130,246,0.1); border-color: rgba(59,130,246,0.3); color: #3b82f6; }
840
931
  .error-message.warning { background: rgba(245,158,11,0.1); border-color: rgba(245,158,11,0.3); color: #f59e0b; }
841
932
  .error-message.error { background: rgba(239,68,68,0.1); border-color: rgba(239,68,68,0.3); color: #ef4444; }
842
933
  .hint { font-size: 12px; color: var(--icpay-muted); margin-top: 6px; }
843
- `],s([vt({type:Object})],f.prototype,"config",2),s([I()],f.prototype,"amountUsd",2),s([I()],f.prototype,"hasUserAmount",2),s([I()],f.prototype,"selectedSymbol",2),s([I()],f.prototype,"processing",2),s([I()],f.prototype,"succeeded",2),s([I()],f.prototype,"availableLedgers",2),s([I()],f.prototype,"errorMessage",2),s([I()],f.prototype,"errorSeverity",2),s([I()],f.prototype,"errorAction",2),s([I()],f.prototype,"walletConnected",2),s([I()],f.prototype,"pendingAction",2),s([I()],f.prototype,"showWalletModal",2),f=s([bt("icpay-amount-input")],f);export{f as ICPayAmountInput,g as ICPayArticlePaywall,v as ICPayCoffeeShop,u as ICPayDonationThermometer,w as ICPayPayButton,m as ICPayPremiumContent,h as ICPayTipJar,Q as applyThemeVars,E as baseStyles,d as createSdk};
934
+
935
+ @media (max-width: 520px) {
936
+ .top-row { grid-template-columns: 1fr; }
937
+ }
938
+ `],s([xt({type:Object})],f.prototype,"config",2),s([T()],f.prototype,"amountUsd",2),s([T()],f.prototype,"hasUserAmount",2),s([T()],f.prototype,"selectedSymbol",2),s([T()],f.prototype,"processing",2),s([T()],f.prototype,"succeeded",2),s([T()],f.prototype,"availableLedgers",2),s([T()],f.prototype,"errorMessage",2),s([T()],f.prototype,"errorSeverity",2),s([T()],f.prototype,"errorAction",2),s([T()],f.prototype,"walletConnected",2),s([T()],f.prototype,"pendingAction",2),s([T()],f.prototype,"showWalletModal",2),f=s([wt("icpay-amount-input")],f);export{f as ICPayAmountInput,g as ICPayArticlePaywall,v as ICPayCoffeeShop,u as ICPayDonationThermometer,w as ICPayPayButton,b as ICPayPremiumContent,h as ICPayTipJar,Q as applyThemeVars,E as baseStyles,d as createSdk};
844
939
  //# sourceMappingURL=index.js.map