import{i as f,a as w,h as I,f as x,C as H,af as l,b as u,r as z,e as W,R as g,N as L,x as F,S as _,E as M,g as Y,W as K}from"./index-B6fu-u6K.js";import{n as d,r as c,c as m,U as $,o as G}from"./if-defined-D6swbWyQ.js";import"./index-CaabtizE.js";import"./index-Bl7lS5oY.js";import{e as O,n as D}from"./ref-CNdtRDdT.js";import"./index-CuJMoJHR.js";import{n as J,s as Q}from"./ConstantsUtil-Dmg8YACJ.js";import"./index-BEFi7f_e.js";import"./index-CZEp7hmv.js";import{S as q}from"./SwapController-B_QyDngB.js";import"./index-CS6mdpde.js";import"./index-B18X2HR0.js";import"./index-BuYxs1kZ.js";import"./index-DUZ-8KUm.js";import"./index-BqLefJXm.js";import"./index-DmDFCnkv.js";const X=f` :host { width: 100%; height: 100px; border-radius: var(--wui-border-radius-s); border: 1px solid var(--wui-color-gray-glass-002); background-color: var(--wui-color-gray-glass-002); transition: background-color var(--wui-ease-out-power-1) var(--wui-duration-lg); will-change: background-color; position: relative; } :host(:hover) { background-color: var(--wui-color-gray-glass-005); } wui-flex { width: 100%; height: fit-content; } wui-button { display: ruby; color: var(--wui-color-fg-100); margin: 0 var(--wui-spacing-xs); } .instruction { position: absolute; top: 50%; transform: translateY(-50%); z-index: 2; } .paste { display: inline-flex; } textarea { background: transparent; width: 100%; font-family: var(--w3m-font-family); font-size: var(--wui-font-size-medium); font-style: normal; font-weight: var(--wui-font-weight-light); line-height: 130%; letter-spacing: var(--wui-letter-spacing-medium); color: var(--wui-color-fg-100); caret-color: var(--wui-color-accent-100); box-sizing: border-box; -webkit-appearance: none; -moz-appearance: textfield; padding: 0px; border: none; outline: none; appearance: none; resize: none; overflow: hidden; } `;var E=function(o,e,i,n){var r=arguments.length,t=r<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,i):n,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")t=Reflect.decorate(o,e,i,n);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(t=(r<3?s(t):r>3?s(e,i,t):s(e,i))||t);return r>3&&t&&Object.defineProperty(e,i,t),t};let A=class extends w{constructor(){super(...arguments),this.inputElementRef=O(),this.instructionElementRef=O(),this.instructionHidden=!!this.value,this.pasting=!1,this.onDebouncedSearch=I.debounce(async e=>{if(!e.length){this.setReceiverAddress("");return}const i=x.state.activeChain;if(I.isAddress(e,i)){this.setReceiverAddress(e);return}try{const r=await H.getEnsAddress(e);if(r){l.setReceiverProfileName(e),l.setReceiverAddress(r);const t=await H.getEnsAvatar(e);l.setReceiverProfileImageUrl(t||void 0)}}catch{this.setReceiverAddress(e)}finally{l.setLoading(!1)}})}firstUpdated(){this.value&&(this.instructionHidden=!0),this.checkHidden()}render(){return u` Type or Paste address `}async focusInput(){var e;this.instructionElementRef.value&&(this.instructionHidden=!0,await this.toggleInstructionFocus(!1),this.instructionElementRef.value.style.pointerEvents="none",(e=this.inputElementRef.value)==null||e.focus(),this.inputElementRef.value&&(this.inputElementRef.value.selectionStart=this.inputElementRef.value.selectionEnd=this.inputElementRef.value.value.length))}async focusInstruction(){var e;this.instructionElementRef.value&&(this.instructionHidden=!1,await this.toggleInstructionFocus(!0),this.instructionElementRef.value.style.pointerEvents="auto",(e=this.inputElementRef.value)==null||e.blur())}async toggleInstructionFocus(e){this.instructionElementRef.value&&await this.instructionElementRef.value.animate([{opacity:e?0:1},{opacity:e?1:0}],{duration:100,easing:"ease",fill:"forwards"}).finished}onBoxClick(){!this.value&&!this.instructionHidden&&this.focusInput()}onBlur(){!this.value&&this.instructionHidden&&!this.pasting&&this.focusInstruction()}checkHidden(){this.instructionHidden&&this.focusInput()}async onPasteClick(){this.pasting=!0;const e=await navigator.clipboard.readText();l.setReceiverAddress(e),this.focusInput()}onInputChange(e){var n;const i=e.target;this.pasting=!1,this.value=(n=e.target)==null?void 0:n.value,i.value&&!this.instructionHidden&&this.focusInput(),l.setLoading(!0),this.onDebouncedSearch(i.value)}setReceiverAddress(e){l.setReceiverAddress(e),l.setReceiverProfileName(void 0),l.setReceiverProfileImageUrl(void 0),l.setLoading(!1)}};A.styles=X;E([d()],A.prototype,"value",void 0);E([c()],A.prototype,"instructionHidden",void 0);E([c()],A.prototype,"pasting",void 0);A=E([m("w3m-input-address")],A);const Z=f` :host { position: relative; display: inline-block; } input { background: transparent; width: 100%; height: auto; font-family: var(--wui-font-family); color: var(--wui-color-fg-100); font-feature-settings: 'case' on; font-size: 32px; font-weight: var(--wui-font-weight-light); caret-color: var(--wui-color-accent-100); line-height: 130%; letter-spacing: -1.28px; box-sizing: border-box; -webkit-appearance: none; -moz-appearance: textfield; padding: 0px; } input::-webkit-outer-spin-button, input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; } input::placeholder { color: var(--wui-color-fg-275); } `;var B=function(o,e,i,n){var r=arguments.length,t=r<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,i):n,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")t=Reflect.decorate(o,e,i,n);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(t=(r<3?s(t):r>3?s(e,i,t):s(e,i))||t);return r>3&&t&&Object.defineProperty(e,i,t),t};let C=class extends w{constructor(){super(...arguments),this.inputElementRef=O(),this.disabled=!1,this.value="",this.placeholder="0"}render(){var e;return(e=this.inputElementRef)!=null&&e.value&&this.value&&(this.inputElementRef.value.value=this.value),u` `}dispatchInputChangeEvent(e){var n,r;const i=e.data;if(i&&((n=this.inputElementRef)!=null&&n.value))if(i===","){const t=this.inputElementRef.value.value.replace(",",".");this.inputElementRef.value.value=t,this.value=`${this.value}${t}`}else J.test(i)||(this.inputElementRef.value.value=this.value.replace(new RegExp(i.replace(Q,"\\$&"),"gu"),""));this.dispatchEvent(new CustomEvent("inputChange",{detail:(r=this.inputElementRef.value)==null?void 0:r.value,bubbles:!0,composed:!0}))}};C.styles=[z,W,Z];B([d({type:Boolean})],C.prototype,"disabled",void 0);B([d({type:String})],C.prototype,"value",void 0);B([d({type:String})],C.prototype,"placeholder",void 0);C=B([m("wui-input-amount")],C);const ee=f` :host { width: 100%; height: 100px; border-radius: var(--wui-border-radius-s); border: 1px solid var(--wui-color-gray-glass-002); background-color: var(--wui-color-gray-glass-002); transition: background-color var(--wui-ease-out-power-1) var(--wui-duration-lg); will-change: background-color; } :host(:hover) { background-color: var(--wui-color-gray-glass-005); } wui-flex { width: 100%; height: fit-content; } wui-button { width: 100%; display: flex; justify-content: flex-end; } wui-input-amount { mask-image: linear-gradient( 270deg, transparent 0px, transparent 8px, black 24px, black 25px, black 32px, black 100% ); } .totalValue { width: 100%; } `;var V=function(o,e,i,n){var r=arguments.length,t=r<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,i):n,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")t=Reflect.decorate(o,e,i,n);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(t=(r<3?s(t):r>3?s(e,i,t):s(e,i))||t);return r>3&&t&&Object.defineProperty(e,i,t),t};let R=class extends w{render(){return u` ${this.buttonTemplate()} ${this.sendValueTemplate()} ${this.maxAmountTemplate()} ${this.actionTemplate()} `}buttonTemplate(){return this.token?u` `:u`Select token`}handleSelectButtonClick(){g.push("WalletSendSelectToken")}sendValueTemplate(){if(this.token&&this.sendTokenAmount){const i=this.token.price*this.sendTokenAmount;return u`${i?`$${L.formatNumberToLocalString(i,2)}`:"Incorrect value"}`}return null}maxAmountTemplate(){return this.token?this.sendTokenAmount&&this.sendTokenAmount>Number(this.token.quantity.numeric)?u` ${$.roundNumber(Number(this.token.quantity.numeric),6,5)} `:u` ${$.roundNumber(Number(this.token.quantity.numeric),6,5)} `:null}actionTemplate(){return this.token?this.sendTokenAmount&&this.sendTokenAmount>Number(this.token.quantity.numeric)?u`Buy`:u`Max`:null}onInputChange(e){l.setTokenAmount(e.detail)}onMaxClick(){if(this.token){const e=L.bigNumber(this.token.quantity.numeric);l.setTokenAmount(Number(e.toFixed(20)))}}onBuyClick(){g.push("OnRampProviders")}};R.styles=ee;V([d({type:Object})],R.prototype,"token",void 0);V([d({type:Number})],R.prototype,"sendTokenAmount",void 0);R=V([m("w3m-input-token")],R);const te=f` :host { display: block; } wui-flex { position: relative; } wui-icon-box { width: 40px; height: 40px; border-radius: var(--wui-border-radius-xs) !important; border: 5px solid var(--wui-color-bg-125); background: var(--wui-color-bg-175); position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 3; } wui-button { --local-border-radius: var(--wui-border-radius-xs) !important; } .inputContainer { height: fit-content; } `;var y=function(o,e,i,n){var r=arguments.length,t=r<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,i):n,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")t=Reflect.decorate(o,e,i,n);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(t=(r<3?s(t):r>3?s(e,i,t):s(e,i))||t);return r>3&&t&&Object.defineProperty(e,i,t),t};let p=class extends w{constructor(){super(),this.unsubscribe=[],this.token=l.state.token,this.sendTokenAmount=l.state.sendTokenAmount,this.receiverAddress=l.state.receiverAddress,this.receiverProfileName=l.state.receiverProfileName,this.loading=l.state.loading,this.message="Preview Send",this.token&&(this.fetchBalances(),this.fetchNetworkPrice()),this.unsubscribe.push(l.subscribe(e=>{this.token=e.token,this.sendTokenAmount=e.sendTokenAmount,this.receiverAddress=e.receiverAddress,this.receiverProfileName=e.receiverProfileName,this.loading=e.loading}))}disconnectedCallback(){this.unsubscribe.forEach(e=>e())}render(){return this.getMessage(),u` ${this.message} `}async fetchBalances(){await l.fetchTokenBalance(),l.fetchNetworkBalance()}async fetchNetworkPrice(){await q.getNetworkTokenPrice()}onButtonClick(){g.push("WalletSendPreview")}getMessage(){var e;this.message="Preview Send",this.receiverAddress&&!I.isAddress(this.receiverAddress,x.state.activeChain)&&(this.message="Invalid Address"),this.receiverAddress||(this.message="Add Address"),this.sendTokenAmount&&this.token&&this.sendTokenAmount>Number(this.token.quantity.numeric)&&(this.message="Insufficient Funds"),this.sendTokenAmount||(this.message="Add Amount"),this.sendTokenAmount&&((e=this.token)!=null&&e.price)&&(this.sendTokenAmount*this.token.price||(this.message="Incorrect Value")),this.token||(this.message="Select Token")}};p.styles=te;y([c()],p.prototype,"token",void 0);y([c()],p.prototype,"sendTokenAmount",void 0);y([c()],p.prototype,"receiverAddress",void 0);y([c()],p.prototype,"receiverProfileName",void 0);y([c()],p.prototype,"loading",void 0);y([c()],p.prototype,"message",void 0);p=y([m("w3m-wallet-send-view")],p);const ie=f` .contentContainer { height: 440px; overflow: scroll; scrollbar-width: none; } .contentContainer::-webkit-scrollbar { display: none; } wui-icon-box { width: 40px; height: 40px; border-radius: var(--wui-border-radius-xxs); } `;var P=function(o,e,i,n){var r=arguments.length,t=r<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,i):n,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")t=Reflect.decorate(o,e,i,n);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(t=(r<3?s(t):r>3?s(e,i,t):s(e,i))||t);return r>3&&t&&Object.defineProperty(e,i,t),t};let b=class extends w{constructor(){super(),this.unsubscribe=[],this.tokenBalances=l.state.tokenBalances,this.search="",this.onDebouncedSearch=I.debounce(e=>{this.search=e}),this.fetchBalancesAndNetworkPrice(),this.unsubscribe.push(l.subscribe(e=>{this.tokenBalances=e.tokenBalances}))}disconnectedCallback(){this.unsubscribe.forEach(e=>e())}render(){return u` ${this.templateSearchInput()} ${this.templateTokens()} `}async fetchBalancesAndNetworkPrice(){var e;(!this.tokenBalances||((e=this.tokenBalances)==null?void 0:e.length)===0)&&(await this.fetchBalances(),await this.fetchNetworkPrice())}async fetchBalances(){await l.fetchTokenBalance(),l.fetchNetworkBalance()}async fetchNetworkPrice(){await q.getNetworkTokenPrice()}templateSearchInput(){return u` `}templateTokens(){var e,i;return this.tokens=(e=this.tokenBalances)==null?void 0:e.filter(n=>{var r;return n.chainId===((r=x.state.activeCaipNetwork)==null?void 0:r.caipNetworkId)}),this.search?this.filteredTokens=(i=this.tokenBalances)==null?void 0:i.filter(n=>n.name.toLowerCase().includes(this.search.toLowerCase())):this.filteredTokens=this.tokens,u` Your tokens ${this.filteredTokens&&this.filteredTokens.length>0?this.filteredTokens.map(n=>u``):u` No tokens found Your tokens will appear here Buy `} `}onBuyClick(){g.push("OnRampProviders")}onInputChange(e){this.onDebouncedSearch(e.detail)}handleTokenClick(e){l.setToken(e),l.setTokenAmount(void 0),g.goBack()}};b.styles=ie;P([c()],b.prototype,"tokenBalances",void 0);P([c()],b.prototype,"tokens",void 0);P([c()],b.prototype,"filteredTokens",void 0);P([c()],b.prototype,"search",void 0);b=P([m("w3m-wallet-send-select-token-view")],b);const ne=f` :host { display: flex; gap: var(--wui-spacing-xs); border-radius: var(--wui-border-radius-3xl); border: 1px solid var(--wui-color-gray-glass-002); background: var(--wui-color-gray-glass-002); padding: var(--wui-spacing-2xs) var(--wui-spacing-xs) var(--wui-spacing-2xs) var(--wui-spacing-s); align-items: center; } wui-avatar, wui-icon, wui-image { width: 32px; height: 32px; border: 1px solid var(--wui-color-gray-glass-002); border-radius: var(--wui-border-radius-3xl); box-shadow: 0 0 0 2px var(--wui-color-gray-glass-002); } `;var N=function(o,e,i,n){var r=arguments.length,t=r<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,i):n,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")t=Reflect.decorate(o,e,i,n);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(t=(r<3?s(t):r>3?s(e,i,t):s(e,i))||t);return r>3&&t&&Object.defineProperty(e,i,t),t};let k=class extends w{constructor(){super(...arguments),this.text="",this.address="",this.isAddress=!1}render(){return u`${this.text} ${this.imageTemplate()}`}imageTemplate(){return this.isAddress?u``:this.imageSrc?u``:u``}};k.styles=[z,W,ne];N([d()],k.prototype,"text",void 0);N([d()],k.prototype,"address",void 0);N([d()],k.prototype,"imageSrc",void 0);N([d({type:Boolean})],k.prototype,"isAddress",void 0);k=N([m("wui-preview-item")],k);const re=f` :host { display: flex; column-gap: var(--wui-spacing-s); padding: 17px 18px 17px var(--wui-spacing-m); width: 100%; background-color: var(--wui-color-gray-glass-002); border-radius: var(--wui-border-radius-xs); color: var(--wui-color-fg-250); } wui-image { width: var(--wui-icon-size-lg); height: var(--wui-icon-size-lg); border-radius: var(--wui-border-radius-3xl); } wui-icon { width: var(--wui-icon-size-lg); height: var(--wui-icon-size-lg); } `;var j=function(o,e,i,n){var r=arguments.length,t=r<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,i):n,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")t=Reflect.decorate(o,e,i,n);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(t=(r<3?s(t):r>3?s(e,i,t):s(e,i))||t);return r>3&&t&&Object.defineProperty(e,i,t),t};let T=class extends w{constructor(){super(...arguments),this.imageSrc=void 0,this.textTitle="",this.textValue=void 0}render(){return u` ${this.textTitle} ${this.templateContent()} `}templateContent(){return this.imageSrc?u``:this.textValue?u` ${this.textValue} `:u``}};T.styles=[z,W,re];j([d()],T.prototype,"imageSrc",void 0);j([d()],T.prototype,"textTitle",void 0);j([d()],T.prototype,"textValue",void 0);T=j([m("wui-list-content")],T);const oe=f` :host { display: flex; width: auto; flex-direction: column; gap: var(--wui-border-radius-1xs); border-radius: var(--wui-border-radius-s); background: var(--wui-color-gray-glass-002); padding: var(--wui-spacing-s) var(--wui-spacing-1xs) var(--wui-spacing-1xs) var(--wui-spacing-1xs); } wui-text { padding: 0 var(--wui-spacing-1xs); } wui-flex { margin-top: var(--wui-spacing-1xs); } .network { cursor: pointer; transition: background-color var(--wui-ease-out-power-1) var(--wui-duration-lg); will-change: background-color; } .network:focus-visible { border: 1px solid var(--wui-color-accent-100); background-color: var(--wui-color-gray-glass-005); -webkit-box-shadow: 0px 0px 0px 4px var(--wui-box-shadow-blue); -moz-box-shadow: 0px 0px 0px 4px var(--wui-box-shadow-blue); box-shadow: 0px 0px 0px 4px var(--wui-box-shadow-blue); } .network:hover { background-color: var(--wui-color-gray-glass-005); } .network:active { background-color: var(--wui-color-gray-glass-010); } `;var U=function(o,e,i,n){var r=arguments.length,t=r<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,i):n,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")t=Reflect.decorate(o,e,i,n);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(t=(r<3?s(t):r>3?s(e,i,t):s(e,i))||t);return r>3&&t&&Object.defineProperty(e,i,t),t};let S=class extends w{render(){return u` Details ${this.networkTemplate()} `}networkTemplate(){var e;return(e=this.caipNetwork)!=null&&e.name?u` this.onNetworkClick(this.caipNetwork)} class="network" textTitle="Network" imageSrc=${G(F.getNetworkImage(this.caipNetwork))} >`:null}onNetworkClick(e){e&&g.push("Networks",{network:e})}};S.styles=oe;U([d()],S.prototype,"receiverAddress",void 0);U([d({type:Object})],S.prototype,"caipNetwork",void 0);S=U([m("w3m-wallet-send-details")],S);const se=f` wui-avatar, wui-image { display: ruby; width: 32px; height: 32px; border-radius: var(--wui-border-radius-3xl); } .sendButton { width: 70%; --local-width: 100% !important; --local-border-radius: var(--wui-border-radius-xs) !important; } .cancelButton { width: 30%; --local-width: 100% !important; --local-border-radius: var(--wui-border-radius-xs) !important; } `;var v=function(o,e,i,n){var r=arguments.length,t=r<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,i):n,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")t=Reflect.decorate(o,e,i,n);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(t=(r<3?s(t):r>3?s(e,i,t):s(e,i))||t);return r>3&&t&&Object.defineProperty(e,i,t),t};let h=class extends w{constructor(){super(),this.unsubscribe=[],this.token=l.state.token,this.sendTokenAmount=l.state.sendTokenAmount,this.receiverAddress=l.state.receiverAddress,this.receiverProfileName=l.state.receiverProfileName,this.receiverProfileImageUrl=l.state.receiverProfileImageUrl,this.caipNetwork=x.state.activeCaipNetwork,this.loading=l.state.loading,this.unsubscribe.push(l.subscribe(e=>{this.token=e.token,this.sendTokenAmount=e.sendTokenAmount,this.receiverAddress=e.receiverAddress,this.receiverProfileName=e.receiverProfileName,this.receiverProfileImageUrl=e.receiverProfileImageUrl,this.loading=e.loading}),x.subscribeKey("activeCaipNetwork",e=>this.caipNetwork=e))}disconnectedCallback(){this.unsubscribe.forEach(e=>e())}render(){var e,i;return u` Send ${this.sendValueTemplate()} To Review transaction carefully Cancel Send `}sendValueTemplate(){if(this.token&&this.sendTokenAmount){const i=this.token.price*this.sendTokenAmount;return u`$${i.toFixed(2)}`}return null}async onSendClick(){var e,i;if(!this.sendTokenAmount||!this.receiverAddress){_.showError("Please enter a valid amount and receiver address");return}try{await l.sendToken(),_.showSuccess("Transaction started"),g.replace("Account")}catch(n){_.showError("Failed to send transaction. Please try again."),console.error("SendController:sendToken - failed to send transaction",n);const r=n instanceof Error?n.message:"Unknown error";M.sendEvent({type:"track",event:"SEND_ERROR",properties:{message:r,isSmartAccount:Y(x.state.activeChain)===K.ACCOUNT_TYPES.SMART_ACCOUNT,token:((e=this.token)==null?void 0:e.symbol)||"",amount:this.sendTokenAmount,network:((i=x.state.activeCaipNetwork)==null?void 0:i.caipNetworkId)||""}})}}onCancelClick(){g.goBack()}};h.styles=se;v([c()],h.prototype,"token",void 0);v([c()],h.prototype,"sendTokenAmount",void 0);v([c()],h.prototype,"receiverAddress",void 0);v([c()],h.prototype,"receiverProfileName",void 0);v([c()],h.prototype,"receiverProfileImageUrl",void 0);v([c()],h.prototype,"caipNetwork",void 0);v([c()],h.prototype,"loading",void 0);h=v([m("w3m-wallet-send-preview-view")],h);export{b as W3mSendSelectTokenView,h as W3mWalletSendPreviewView,p as W3mWalletSendView};