1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8430],{77282:function(t,e,o){o.d(e,{f:function(){return s}});var i=o(86949),n=o(73932),r=o(68343);let a=(0,i.sj)({message:"",open:!1,triggerRect:{width:0,height:0,top:0,left:0},variant:"shade"}),s=(0,r.P)({state:a,subscribe:t=>(0,i.Ld)(a,()=>t(a)),subscribeKey:(t,e)=>(0,n.VW)(a,t,e),showTooltip({message:t,triggerRect:e,variant:o}){a.open=!0,a.message=t,a.triggerRect=e,a.variant=o},hide(){a.open=!1,a.message="",a.triggerRect={width:0,height:0,top:0,left:0}}})},58430:function(t,e,o){o.r(e),o.d(e,{W3mSwapPreviewView:function(){return R},W3mSwapSelectTokenView:function(){return M},W3mSwapView:function(){return I}});var i=o(19064),n=o(59662),r=o(62411),a=o(4511),s=o(83966),l=o(59757),c=o(30010),u=o(83241),p=o(83662),d=o(51440),h=o(28740);o(37826),o(82100),o(85642),o(68390);var w=o(22192),g=o(47205);o(71799),o(30553);var b=i.iv` 2 :host { 3 width: 100%; 4 } 5 6 .details-container > wui-flex { 7 background: var(--wui-color-gray-glass-002); 8 border-radius: var(--wui-border-radius-xxs); 9 width: 100%; 10 } 11 12 .details-container > wui-flex > button { 13 border: none; 14 background: none; 15 padding: var(--wui-spacing-s); 16 border-radius: var(--wui-border-radius-xxs); 17 cursor: pointer; 18 } 19 20 .details-content-container { 21 padding: var(--wui-spacing-1xs); 22 padding-top: 0px; 23 display: flex; 24 align-items: center; 25 justify-content: center; 26 } 27 28 .details-content-container > wui-flex { 29 width: 100%; 30 } 31 32 .details-row { 33 width: 100%; 34 padding: var(--wui-spacing-s); 35 padding-left: var(--wui-spacing-s); 36 padding-right: var(--wui-spacing-1xs); 37 border-radius: calc(var(--wui-border-radius-5xs) + var(--wui-border-radius-4xs)); 38 background: var(--wui-color-gray-glass-002); 39 } 40 41 .details-row-title { 42 white-space: nowrap; 43 } 44 45 .details-row.provider-free-row { 46 padding-right: var(--wui-spacing-xs); 47 } 48`,x=function(t,e,o,i){var n,r=arguments.length,a=r<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,o):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,o,i);else for(var s=t.length-1;s>=0;s--)(n=t[s])&&(a=(r<3?n(a):r>3?n(e,o,a):n(e,o))||a);return r>3&&a&&Object.defineProperty(e,o,a),a};let f=g.bq.CONVERT_SLIPPAGE_TOLERANCE,m=class extends i.oi{constructor(){super(),this.unsubscribe=[],this.networkName=l.R.state.activeCaipNetwork?.name,this.detailsOpen=!1,this.sourceToken=c.nY.state.sourceToken,this.toToken=c.nY.state.toToken,this.toTokenAmount=c.nY.state.toTokenAmount,this.sourceTokenPriceInUSD=c.nY.state.sourceTokenPriceInUSD,this.toTokenPriceInUSD=c.nY.state.toTokenPriceInUSD,this.priceImpact=c.nY.state.priceImpact,this.maxSlippage=c.nY.state.maxSlippage,this.networkTokenSymbol=c.nY.state.networkTokenSymbol,this.inputError=c.nY.state.inputError,this.unsubscribe.push(...[c.nY.subscribe(t=>{this.sourceToken=t.sourceToken,this.toToken=t.toToken,this.toTokenAmount=t.toTokenAmount,this.priceImpact=t.priceImpact,this.maxSlippage=t.maxSlippage,this.sourceTokenPriceInUSD=t.sourceTokenPriceInUSD,this.toTokenPriceInUSD=t.toTokenPriceInUSD,this.inputError=t.inputError})])}render(){let t=this.toTokenAmount&&this.maxSlippage?r.C.bigNumber(this.toTokenAmount).minus(this.maxSlippage).toString():null;if(!this.sourceToken||!this.toToken||this.inputError)return null;let e=this.sourceTokenPriceInUSD&&this.toTokenPriceInUSD?1/this.toTokenPriceInUSD*this.sourceTokenPriceInUSD:0;return i.dy` 49 <wui-flex flexDirection="column" alignItems="center" gap="1xs" class="details-container"> 50 <wui-flex flexDirection="column"> 51 <button @click=${this.toggleDetails.bind(this)}> 52 <wui-flex justifyContent="space-between" .padding=${["0","xs","0","xs"]}> 53 <wui-flex justifyContent="flex-start" flexGrow="1" gap="xs"> 54 <wui-text variant="small-400" color="fg-100"> 55 1 ${this.sourceToken.symbol} = 56 ${h.Hg.formatNumberToLocalString(e,3)} 57 ${this.toToken.symbol} 58 </wui-text> 59 <wui-text variant="small-400" color="fg-200"> 60 $${h.Hg.formatNumberToLocalString(this.sourceTokenPriceInUSD)} 61 </wui-text> 62 </wui-flex> 63 <wui-icon name="chevronBottom"></wui-icon> 64 </wui-flex> 65 </button> 66 ${this.detailsOpen?i.dy` 67 <wui-flex flexDirection="column" gap="xs" class="details-content-container"> 68 ${this.priceImpact?i.dy` <wui-flex flexDirection="column" gap="xs"> 69 <wui-flex 70 justifyContent="space-between" 71 alignItems="center" 72 class="details-row" 73 > 74 <wui-flex alignItems="center" gap="xs"> 75 <wui-text class="details-row-title" variant="small-400" color="fg-150"> 76 Price impact 77 </wui-text> 78 <w3m-tooltip-trigger 79 text="Price impact reflects the change in market price due to your trade" 80 > 81 <wui-icon size="xs" color="fg-250" name="infoCircle"></wui-icon> 82 </w3m-tooltip-trigger> 83 </wui-flex> 84 <wui-flex> 85 <wui-text variant="small-400" color="fg-200"> 86 ${h.Hg.formatNumberToLocalString(this.priceImpact,3)}% 87 </wui-text> 88 </wui-flex> 89 </wui-flex> 90 </wui-flex>`:null} 91 ${this.maxSlippage&&this.sourceToken.symbol?i.dy`<wui-flex flexDirection="column" gap="xs"> 92 <wui-flex 93 justifyContent="space-between" 94 alignItems="center" 95 class="details-row" 96 > 97 <wui-flex alignItems="center" gap="xs"> 98 <wui-text class="details-row-title" variant="small-400" color="fg-150"> 99 Max. slippage 100 </wui-text> 101 <w3m-tooltip-trigger 102 text=${`Max slippage sets the minimum amount you must receive for the transaction to proceed. ${t?`Transaction will be reversed if you receive less than ${h.Hg.formatNumberToLocalString(t,6)} ${this.toToken.symbol} due to price changes.`:""}`} 103 > 104 <wui-icon size="xs" color="fg-250" name="infoCircle"></wui-icon> 105 </w3m-tooltip-trigger> 106 </wui-flex> 107 <wui-flex> 108 <wui-text variant="small-400" color="fg-200"> 109 ${h.Hg.formatNumberToLocalString(this.maxSlippage,6)} 110 ${this.toToken.symbol} ${f}% 111 </wui-text> 112 </wui-flex> 113 </wui-flex> 114 </wui-flex>`:null} 115 <wui-flex flexDirection="column" gap="xs"> 116 <wui-flex 117 justifyContent="space-between" 118 alignItems="center" 119 class="details-row provider-free-row" 120 > 121 <wui-flex alignItems="center" gap="xs"> 122 <wui-text class="details-row-title" variant="small-400" color="fg-150"> 123 Provider fee 124 </wui-text> 125 </wui-flex> 126 <wui-flex> 127 <wui-text variant="small-400" color="fg-200">0.85%</wui-text> 128 </wui-flex> 129 </wui-flex> 130 </wui-flex> 131 </wui-flex> 132 `:null} 133 </wui-flex> 134 </wui-flex> 135 `}toggleDetails(){this.detailsOpen=!this.detailsOpen}};
135m.styles=[b],x([(0,n.SB)()],m.prototype,"networkName",void 0),x([(0,n.Cb)()],m.prototype,"detailsOpen",void 0),x([(0,n.SB)()],m.prototype,"sourceToken",void 0),x([(0,n.SB)()],m.prototype,"toToken",void 0),x([(0,n.SB)()],m.prototype,"toTokenAmount",void 0),x([(0,n.SB)()],m.prototype,"sourceTokenPriceInUSD",void 0),x([(0,n.SB)()],m.prototype,"toTokenPriceInUSD",void 0),x([(0,n.SB)()],m.prototype,"priceImpact",void 0),x([(0,n.SB)()],m.prototype,"maxSlippage",void 0),x([(0,n.SB)()],m.prototype,"networkTokenSymbol",void 0),x([(0,n.SB)()],m.prototype,"inputError",void 0),m=x([(0,h.Mo)("w3m-swap-details")],m),o(91833);var k=i.iv` 136 :host { 137 width: 100%; 138 } 139 140 :host > wui-flex { 141 display: flex; 142 flex-direction: row; 143 justify-content: space-between; 144 align-items: center; 145 border-radius: var(--wui-border-radius-s); 146 padding: var(--wui-spacing-xl); 147 padding-right: var(--wui-spacing-s); 148 background-color: var(--wui-color-gray-glass-002); 149 box-shadow: inset 0px 0px 0px 1px var(--wui-color-gray-glass-002); 150 width: 100%; 151 height: 100px; 152 box-sizing: border-box; 153 position: relative; 154 } 155 156 wui-shimmer.market-value { 157 opacity: 0; 158 } 159 160 :host > wui-flex > svg.input_mask { 161 position: absolute; 162 inset: 0; 163 z-index: 5; 164 } 165 166 :host wui-flex .input_mask__border, 167 :host wui-flex .input_mask__background { 168 transition: fill var(--wui-duration-md) var(--wui-ease-out-power-1); 169 will-change: fill; 170 } 171 172 :host wui-flex .input_mask__border { 173 fill: var(--wui-color-gray-glass-020); 174 } 175 176 :host wui-flex .input_mask__background { 177 fill: var(--wui-color-gray-glass-002); 178 } 179`,v=function(t,e,o,i){var n,r=arguments.length,a=r<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,o):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,o,i);else for(var s=t.length-1;s>=0;s--)(n=t[s])&&(a=(r<3?n(a):r>3?n(e,o,a):n(e,o))||a);return r>3&&a&&Object.defineProperty(e,o,a),a};let y=class extends i.oi{constructor(){super(...arguments),this.target="sourceToken"}render(){return i.dy` 180 <wui-flex class justifyContent="space-between"> 181 <wui-flex 182 flex="1" 183 flexDirection="column" 184 alignItems="flex-start" 185 justifyContent="center" 186 class="swap-input" 187 gap="xxs" 188 > 189 <wui-shimmer width="80px" height="40px" borderRadius="xxs" variant="light"></wui-shimmer> 190 </wui-flex> 191 ${this.templateTokenSelectButton()} 192 </wui-flex> 193 `}templateTokenSelectButton(){return i.dy` 194 <wui-flex 195 class="swap-token-button" 196 flexDirection="column" 197 alignItems="flex-end" 198 justifyContent="center" 199 gap="xxs" 200 > 201 <wui-shimmer width="80px" height="40px" borderRadius="3xl" variant="light"></wui-shimmer> 202 </wui-flex> 203 `}};y.styles=[k],v([(0,n.Cb)()],y.prototype,"target",void 0),y=v([(0,h.Mo)("w3m-swap-input-skeleton")],y);let T={numericInputKeyDown(t,e,o){let i=t.metaKey||t.ctrlKey,n=t.key,r=n.toLocaleLowerCase(),a=","===n,s="."===n,l=n>="0"&&n<="9";i||"a"!==r&&"c"!==r&&"v"!==r&&"x"!==r||t.preventDefault(),"0"!==e||a||s||"0"!==n||t.preventDefault(),"0"===e&&l&&(o(n),t.preventDefault()),(a||s)&&(e||(o("0."),t.preventDefault()),(e?.includes(".")||e?.includes(","))&&t.preventDefault()),l||["Backspace","Meta","Ctrl","a","A","c","C","x","X","v","V","ArrowLeft","ArrowRight","Tab"].includes(n)||s||a||t.preventDefault()}};o(32835);var S=i.iv` 204 :host > wui-flex { 205 display: flex; 206 flex-direction: row; 207 justify-content: space-between; 208 align-items: center; 209 border-radius: var(--wui-border-radius-s); 210 background-color: var(--wui-color-gray-glass-002); 211 padding: var(--wui-spacing-xl); 212 padding-right: var(--wui-spacing-s); 213 width: 100%; 214 height: 100px; 215 box-sizing: border-box; 216 box-shadow: inset 0px 0px 0px 1px var(--wui-color-gray-glass-002); 217 position: relative; 218 transition: box-shadow var(--wui-ease-out-power-1) var(--wui-duration-lg); 219 will-change: background-color; 220 } 221 222 :host wui-flex.focus { 223 box-shadow: inset 0px 0px 0px 1px var(--wui-color-gray-glass-005); 224 } 225 226 :host > wui-flex .swap-input, 227 :host > wui-flex .swap-token-button { 228 z-index: 10; 229 } 230 231 :host > wui-flex .swap-input { 232 -webkit-mask-image: linear-gradient( 233 270deg, 234 transparent 0px, 235 transparent 8px, 236 black 24px, 237 black 25px, 238 black 32px, 239 black 100% 240 ); 241 mask-image: linear-gradient( 242 270deg, 243 transparent 0px, 244 transparent 8px, 245 black 24px, 246 black 25px, 247 black 32px, 248 black 100% 249 ); 250 } 251 252 :host > wui-flex .swap-input input { 253 background: none; 254 border: none; 255 height: 42px; 256 width: 100%; 257 font-size: 32px; 258 font-style: normal; 259 font-weight: 400; 260 line-height: 130%; 261 letter-spacing: -1.28px; 262 outline: none; 263 caret-color: var(--wui-color-accent-100); 264 color: var(--wui-color-fg-100); 265 padding: 0px; 266 } 267 268 :host > wui-flex .swap-input input:focus-visible { 269 outline: none; 270 } 271 272 :host > wui-flex .swap-input input::-webkit-outer-spin-button, 273 :host > wui-flex .swap-input input::-webkit-inner-spin-button { 274 -webkit-appearance: none; 275 margin: 0; 276 } 277 278 .max-value-button { 279 background-color: transparent; 280 border: none; 281 cursor: pointer; 282 color: var(--wui-color-gray-glass-020); 283 padding-left: 0px; 284 } 285 286 .market-value { 287 min-height: 18px; 288 } 289`,$=function(t,e,o,i){var n,r=arguments.length,a=r<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,o):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,o,i);else for(var s=t.length-1;s>=0;s--)(n=t[s])&&(a=(r<3?n(a):r>3?n(e,o,a):n(e,o))||a);return r>3&&a&&Object.defineProperty(e,o,a),a};let C=class extends i.oi{constructor(){super(...arguments),this.focused=!1,this.price=0,this.target="sourceToken",this.onSetAmount=null,this.onSetMaxValue=null}render(){let t=this.marketValue||"0",e=r.C.bigNumber(t).gt("0");return i.dy` 290 <wui-flex class="${this.focused?"focus":""}" justifyContent="space-between"> 291 <wui-flex 292 flex="1" 293 flexDirection="column" 294 alignItems="flex-start" 295 justifyContent="center" 296 class="swap-input" 297 > 298 <input 299 data-testid="swap-input-${this.target}" 300 @focusin=${()=>this.onFocusChange(!0)} 301 @focusout=${()=>this.onFocusChange(!1)} 302 ?disabled=${this.disabled} 303 .value=${this.value}
304 @input=${this.dispatchInputChangeEvent} 305 @keydown=${this.handleKeydown} 306 placeholder="0" 307 type="text" 308 inputmode="decimal" 309 /> 310 <wui-text class="market-value" variant="small-400" color="fg-200"> 311 ${e?`$${h.Hg.formatNumberToLocalString(this.marketValue,2)}`:null} 312 </wui-text> 313 </wui-flex> 314 ${this.templateTokenSelectButton()} 315 </wui-flex> 316 `}handleKeydown(t){return T.numericInputKeyDown(t,this.value,t=>this.onSetAmount?.(this.target,t))}dispatchInputChangeEvent(t){if(!this.onSetAmount)return;let e=t.target.value.replace(/[^0-9.]/gu,"");","===e||"."===e?this.onSetAmount(this.target,"0."):e.endsWith(",")?this.onSetAmount(this.target,e.replace(",",".")):this.onSetAmount(this.target,e)}setMaxValueToInput(){this.onSetMaxValue?.(this.target,this.balance)}templateTokenSelectButton(){return this.token?i.dy` 317 <wui-flex 318 class="swap-token-button" 319 flexDirection="column" 320 alignItems="flex-end" 321 justifyContent="center" 322 gap="xxs" 323 > 324 <wui-token-button 325 data-testid="swap-input-token-${this.target}" 326 text=${this.token.symbol} 327 imageSrc=${this.token.logoUri} 328 @click=${this.onSelectToken.bind(this)} 329 > 330 </wui-token-button> 331 <wui-flex alignItems="center" gap="xxs"> ${this.tokenBalanceTemplate()} </wui-flex> 332 </wui-flex> 333 `:i.dy` <wui-button 334 data-testid="swap-select-token-button-${this.target}" 335 class="swap-token-button" 336 size="md" 337 variant="accent" 338 @click=${this.onSelectToken.bind(this)} 339 > 340 Select token 341 </wui-button>`}tokenBalanceTemplate(){let t=r.C.multiply(this.balance,this.price),e=!!t&&t?.gt(5e-5);return i.dy` 342 ${e?i.dy`<wui-text variant="small-400" color="fg-200"> 343 ${h.Hg.formatNumberToLocalString(this.balance,2)} 344 </wui-text>`:null} 345 ${"sourceToken"===this.target?this.tokenActionButtonTemplate(e):null} 346 `}tokenActionButtonTemplate(t){return t?i.dy` <button class="max-value-button" @click=${this.setMaxValueToInput.bind(this)}> 347 <wui-text color="accent-100" variant="small-600">Max</wui-text> 348 </button>`:i.dy` <button class="max-value-button" @click=${this.onBuyToken.bind(this)}> 349 <wui-text color="accent-100" variant="small-600">Buy</wui-text> 350 </button>`}onFocusChange(t){this.focused=t}onSelectToken(){d.X.sendEvent({type:"track",event:"CLICK_SELECT_TOKEN_TO_SWAP"}),a.RouterController.push("SwapSelectToken",{target:this.target})}onBuyToken(){a.RouterController.push("OnRampProviders")}};C.styles=[S],$([(0,n.Cb)()],C.prototype,"focused",void 0),$([(0,n.Cb)()],C.prototype,"balance",void 0),$([(0,n.Cb)()],C.prototype,"value",void 0),$([(0,n.Cb)()],C.prototype,"price",void 0),$([(0,n.Cb)()],C.prototype,"marketValue",void 0),$([(0,n.Cb)()],C.prototype,"disabled",void 0),$([(0,n.Cb)()],C.prototype,"target",void 0),$([(0,n.Cb)()],C.prototype,"token",void 0),$([(0,n.Cb)()],C.prototype,"onSetAmount",void 0),$([(0,n.Cb)()],C.prototype,"onSetMaxValue",void 0),C=$([(0,h.Mo)("w3m-swap-input")],C);var A=i.iv` 351 :host > wui-flex:first-child { 352 overflow-y: auto; 353 overflow-x: hidden; 354 scrollbar-width: none; 355 } 356 357 :host > wui-flex:first-child::-webkit-scrollbar {
358 display: none; 359 } 360 361 wui-loading-hexagon { 362 position: absolute; 363 } 364 365 .action-button { 366 width: 100%; 367 border-radius: var(--wui-border-radius-xs); 368 } 369 370 .action-button:disabled { 371 border-color: 1px solid var(--wui-color-gray-glass-005); 372 } 373 374 .swap-inputs-container { 375 position: relative; 376 } 377 378 .replace-tokens-button-container { 379 display: flex; 380 justify-content: center; 381 align-items: center; 382 position: absolute; 383 top: 50%; 384 left: 50%; 385 transform: translate(-50%, -50%); 386 gap: var(--wui-spacing-1xs); 387 border-radius: var(--wui-border-radius-xs); 388 background-color: var(--wui-color-modal-bg-base); 389 padding: var(--wui-spacing-xxs); 390 } 391 392 .replace-tokens-button-container > button { 393 display: flex; 394 justify-content: center; 395 align-items: center; 396 height: 40px; 397 width: 40px; 398 padding: var(--wui-spacing-xs); 399 border: none; 400 border-radius: var(--wui-border-radius-xxs); 401 background: var(--wui-color-gray-glass-002); 402 transition: background-color var(--wui-duration-md) var(--wui-ease-out-power-1); 403 will-change: background-color; 404 z-index: 20; 405 } 406 407 .replace-tokens-button-container > button:hover { 408 background: var(--wui-color-gray-glass-005); 409 } 410 411 .details-container > wui-flex { 412 background: var(--wui-color-gray-glass-002); 413 border-radius: var(--wui-border-radius-xxs); 414 width: 100%; 415 } 416 417 .details-container > wui-flex > button { 418 border: none; 419 background: none; 420 padding: var(--wui-spacing-s); 421 border-radius: var(--wui-border-radius-xxs); 422 transition: background 0.2s linear; 423 } 424 425 .details-container > wui-flex > button:hover { 426 background: var(--wui-color-gray-glass-002); 427 } 428 429 .details-content-container { 430 padding: var(--wui-spacing-1xs); 431 display: flex; 432 align-items: center; 433 justify-content: center; 434 } 435 436 .details-content-container > wui-flex { 437 width: 100%; 438 } 439 440 .details-row { 441 width: 100%; 442 padding: var(--wui-spacing-s) var(--wui-spacing-xl); 443 border-radius: var(--wui-border-radius-xxs); 444 background: var(--wui-color-gray-glass-002); 445 } 446`,B=function(t,e,o,i){var n,r=arguments.length,a=r<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,o):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,o,i);else for(var s=t.length-1;s>=0;s--)(n=t[s])&&(a=(r<3?n(a):r>3?n(e,o,a):n(e,o))||a);return r>3&&a&&Object.defineProperty(e,o,a),a};let I=class extends i.oi{constructor(){super(),this.unsubscribe=[],this.initialParams=a.RouterController.state.data?.swap,this.detailsOpen=!1,this.caipAddress=s.AccountController.state.caipAddress,this.caipNetworkId=l.R.state.activeCaipNetwork?.caipNetworkId,this.initialized=c.nY.state.initialized,this.loadingQuote=c.nY.state.loadingQuote,this.loadingPrices=c.nY.state.loadingPrices,this.loadingTransaction=c.nY.state.loadingTransaction,this.sourceToken=c.nY.state.sourceToken,this.sourceTokenAmount=c.nY.state.sourceTokenAmount,this.sourceTokenPriceInUSD=c.nY.state.sourceTokenPriceInUSD,this.toToken=c.nY.state.toToken,this.toTokenAmount=c.nY.state.toTokenAmount,this.toTokenPriceInUSD=c.nY.state.toTokenPriceInUSD,this.inputError=c.nY.state.inputError,this.fetchError=c.nY.state.fetchError,this.onDebouncedGetSwapCalldata=u.j.debounce(async()=>{await c.nY.swapTokens()},200),l.R.subscribeKey("activeCaipNetwork",t=>this.onCaipNetworkChange({newCaipNetwork:t,resetSwapState:!0,initializeSwapState:!1})),s.AccountController.subscribeKey("caipAddress",t=>this.onCaipAddressChange({newCaipAddress:t,resetSwapState:!0,initializeSwapState:!1})),this.unsubscribe.push(...[l.R.subscribeKey("activeCaipNetwork",t=>this.onCaipNetworkChange({newCaipNetwork:t,resetSwapState:!1,initializeSwapState:!0})),s.AccountController.subscribeKey("caipAddress",t=>this.onCaipAddressChange({newCaipAddress:t,resetSwapState:!1,initializeSwapState:!0})),p.I.subscribeKey("open",t=>{t||c.nY.resetState()}),a.RouterController.subscribeKey("view",t=>{t.includes("Swap")||c.nY.resetValues()}),c.nY.subscribe(t=>{this.initialized=t.initialized,this.loadingQuote=t.loadingQuote,this.loadingPrices=t.loadingPrices,this.loadingTransaction=t.loadingTransaction,this.sourceToken=t.sourceToken,this.sourceTokenAmount=t.sourceTokenAmount,this.sourceTokenPriceInUSD=t.sourceTokenPriceInUSD,this.toToken=t.toToken,this.toTokenAmount=t.toTokenAmount,this.toTokenPriceInUSD=t.toTokenPriceInUSD,this.inputError=t.inputError,this.fetchError=t.fetchError})])}async firstUpdated(){c.nY.initializeState(),this.watchTokensAndValues(),await this.handleSwapParameters()}disconnectedCallback(){this.unsubscribe.forEach(t=>t?.()),clearInterval(this.interval)}render(){return i.dy` 447 <wui-flex flexDirection="column" .padding=${["0","l","l","l"]} gap="s"> 448 ${this.initialized?this.templateSwap():this.templateLoading()} 449 </wui-flex> 450 `}watchTokensAndValues(){this.interval=setInterval(()=>{c.nY.getNetworkTokenPrice(),c.nY.getMyTokensWithBalance(),c.nY.swapTokens()},1e4)}templateSwap(){return i.dy` 451 <wui-flex flexDirection="column" gap="s"> 452 <wui-flex flexDirection="column" alignItems="center" gap="xs" class="swap-inputs-container"> 453 ${this.templateTokenInput("sourceToken",this.sourceToken)} 454 ${this.templateTokenInput("toToken",this.toToken)} ${this.templateReplaceTokensButton()} 455 </wui-flex> 456 ${this.templateDetails()} ${this.templateActionButton()} 457 </wui-flex> 458 `}actionButtonLabel(){return this.fetchError?"Swap":this.sourceToken&&this.toToken?this.sourceTokenAmount?this.inputError?this.inputError:"Review swap":"Enter amount":"Select token"}templateReplaceTokensButton(){return i.dy` 459 <wui-flex class="replace-tokens-button-container"> 460 <button @click=${this.onSwitchTokens.bind(this)}> 461 <wui-icon name="recycleHorizontal" color="fg-250" size="lg"></wui-icon> 462 </button> 463 </wui-flex> 464 `}templateLoading(){return i.dy` 465 <wui-flex flexDirection="column" gap="l"> 466 <wui-flex flexDirection="column" alignItems="center" gap="xs" class="swap-inputs-container"> 467 <w3m-swap-input-skeleton target="sourceToken"></w3m-swap-input-skeleton> 468 <w3m-swap-input-skeleton target="toToken"></w3m-swap-input-skeleton> 469 ${this.templateReplaceTokensButton()} 470 </wui-flex> 471 ${this.templateActionButton()} 472 </wui-flex> 473 `}templateTokenInput(t,e){let o=c.nY.state.myTokensWithBalance?.find(t=>t?.address===e?.address),n="toToken"===t?this.toTokenAmount:this.sourceTokenAmount,a="toToken"===t?this.toTokenPriceInUSD:this.sourceTokenPriceInUSD,s=r.C.parseLocalStringToNumber(n)*a;return i.dy`<w3m-swap-input 474 .value=${"toToken"===t?this.toTokenAmount:this.sourceTokenAmount} 475 .disabled=${"toToken"===t} 476 .onSetAmount=${this.handleChangeAmount.bind(this)} 477 target=${t} 478 .token=${e} 479 .balance=${o?.quantity?.numeric} 480 .price=${o?.price} 481 .marketValue=${s} 482 .onSetMaxValue=${this.onSetMaxValue.bind(this)} 483 ></w3m-swap-input>`}onSetMaxValue(t,e){let o=r.C.bigNumber(e||"0");this.handleChangeAmount(t,o.gt(0)?o.toFixed(20):"0")}templateDetails(){return this.sourceToken&&this.toToken&&!this.inputError?i.dy`<w3m-swap-details .detailsOpen=${this.detailsOpen}></w3m-swap-details>`:null}handleChangeAmount(t,e){c.nY.clearError(),"sourceToken"===t?c.nY.setSourceTokenAmount(e):c.nY.setToTokenAmount(e),this.onDebouncedGetSwapCalldata()}templateActionButton(){let t=!this.toToken||!this.sourceToken,e=!this.sourceTokenAmount,o=this.loadingQuote||this.loadingPrices||this.loadingTransaction,n=o||t||e||this.inputError;return i.dy` <wui-flex gap="xs"> 484 <wui-button 485 data-testid="swap-action-button" 486 class="action-button" 487 fullWidth 488 size="lg" 489 borderRadius="xs" 490 variant=${t?"neutral":"main"} 491 .loading=${o} 492 .disabled=${n} 493 @click=${this.onSwapPreview.bind(this)} 494 > 495 ${this.actionButtonLabel()} 496 </wui-button>
496 497 </wui-flex>`}onSwitchTokens(){c.nY.switchTokens()}async onSwapPreview(){let t=l.R.state.activeChain;this.fetchError&&await c.nY.swapTokens(),d.X.sendEvent({type:"track",event:"INITIATE_SWAP",properties:{network:this.caipNetworkId||"",swapFromToken:this.sourceToken?.symbol||"",swapToToken:this.toToken?.symbol||"",swapFromAmount:this.sourceTokenAmount||"",swapToAmount:this.toTokenAmount||"",isSmartAccount:s.AccountController.state.preferredAccountTypes?.[t]===w.y_.ACCOUNT_TYPES.SMART_ACCOUNT}}),a.RouterController.push("SwapPreview")}async handleSwapParameters(){if(this.initialParams){if(!c.nY.state.initialized){let t=new Promise(t=>{let e=c.nY.subscribeKey("initialized",o=>{o&&(e?.(),t())})});await t}await this.setSwapParameters(this.initialParams)}}async setSwapParameters({amount:t,fromToken:e,toToken:o}){if(!c.nY.state.tokens||!c.nY.state.myTokensWithBalance){let t=new Promise(t=>{let e=c.nY.subscribeKey("myTokensWithBalance",o=>{o&&o.length>0&&(e?.(),t())});setTimeout(()=>{e?.(),t()},5e3)});await t}let i=[...c.nY.state.tokens||[],...c.nY.state.myTokensWithBalance||[]];if(e){let t=i.find(t=>t.symbol.toLowerCase()===e.toLowerCase());t&&c.nY.setSourceToken(t)}if(o){let t=i.find(t=>t.symbol.toLowerCase()===o.toLowerCase());t&&c.nY.setToToken(t)}t&&!isNaN(Number(t))&&c.nY.setSourceTokenAmount(t)}onCaipAddressChange({newCaipAddress:t,resetSwapState:e,initializeSwapState:o}){this.caipAddress!==t&&(this.caipAddress=t,e&&c.nY.resetState(),o&&c.nY.initializeState())}onCaipNetworkChange({newCaipNetwork:t,resetSwapState:e,initializeSwapState:o}){this.caipNetworkId!==t?.caipNetworkId&&(this.caipNetworkId=t?.caipNetworkId,e&&c.nY.resetState(),o&&c.nY.initializeState())}};I.styles=A,B([(0,n.Cb)({type:Object})],I.prototype,"initialParams",void 0),B([(0,n.SB)()],I.prototype,"interval",void 0),B([(0,n.SB)()],I.prototype,"detailsOpen",void 0),B([(0,n.SB)()],I.prototype,"caipAddress",void 0),B([(0,n.SB)()],I.prototype,"caipNetworkId",void 0),B([(0,n.SB)()],I.prototype,"initialized",void 0),B([(0,n.SB)()],I.prototype,"loadingQuote",void 0),B([(0,n.SB)()],I.prototype,"loadingPrices",void 0),B([(0,n.SB)()],I.prototype,"loadingTransaction",void 0),B([(0,n.SB)()],I.prototype,"sourceToken",void 0),B([(0,n.SB)()],I.prototype,"sourceTokenAmount",void 0),B([(0,n.SB)()],I.prototype,"sourceTokenPriceInUSD",void 0),B([(0,n.SB)()],I.prototype,"toToken",void 0),B([(0,n.SB)()],I.prototype,"toTokenAmount",void 0),B([(0,n.SB)()],I.prototype,"toTokenPriceInUSD",void 0),B([(0,n.SB)()],I.prototype,"inputError",void 0),B([(0,n.SB)()],I.prototype,"fetchError",void 0),I=B([(0,h.Mo)("w3m-swap-view")],I);var P=i.iv` 498 :host > wui-flex:first-child { 499 overflow-y: auto; 500 overflow-x: hidden; 501 scrollbar-width: none; 502 } 503 504 :host > wui-flex:first-child::-webkit-scrollbar {
505 display: none; 506 } 507 508 .preview-container, 509 .details-container { 510 width: 100%; 511 } 512 513 .token-image { 514 width: 24px; 515 height: 24px; 516 box-shadow: 0 0 0 2px var(--wui-color-gray-glass-005); 517 border-radius: 12px; 518 } 519 520 wui-loading-hexagon { 521 position: absolute; 522 } 523 524 .token-item { 525 display: flex; 526 align-items: center; 527 justify-content: center; 528 gap: var(--wui-spacing-xxs); 529 padding: var(--wui-spacing-xs); 530 height: 40px; 531 border: none; 532 border-radius: 80px; 533 background: var(--wui-color-gray-glass-002); 534 box-shadow: inset 0 0 0 1px var(--wui-color-gray-glass-002); 535 cursor: pointer; 536 transition: background 0.2s linear; 537 } 538 539 .token-item:hover { 540 background: var(--wui-color-gray-glass-005); 541 } 542 543 .preview-token-details-container { 544 width: 100%; 545 } 546 547 .details-row { 548 width: 100%; 549 padding: var(--wui-spacing-s) var(--wui-spacing-xl); 550 border-radius: var(--wui-border-radius-xxs); 551 background: var(--wui-color-gray-glass-002); 552 } 553 554 .action-buttons-container { 555 width: 100%; 556 gap: var(--wui-spacing-xs); 557 } 558 559 .action-buttons-container > button { 560 display: flex; 561 align-items: center; 562 justify-content: center; 563 background: transparent; 564 height: 48px; 565 border-radius: var(--wui-border-radius-xs); 566 border: none; 567 box-shadow: inset 0 0 0 1px var(--wui-color-gray-glass-010); 568 } 569 570 .action-buttons-container > button:disabled { 571 opacity: 0.8; 572 cursor: not-allowed; 573 } 574 575 .action-button > wui-loading-spinner { 576 display: inline-block; 577 } 578 579 .cancel-button:hover, 580 .action-button:hover { 581 cursor: pointer; 582 } 583 584 .action-buttons-container > wui-button.cancel-button { 585 flex: 2; 586 } 587 588 .action-buttons-container > wui-button.action-button { 589 flex: 4; 590 } 591 592 .action-buttons-container > button.action-button > wui-text { 593 color: white; 594 } 595 596 .details-container > wui-flex { 597 background: var(--wui-color-gray-glass-002); 598 border-radius: var(--wui-border-radius-xxs); 599 width: 100%; 600 } 601 602 .details-container > wui-flex > button { 603 border: none; 604 background: none; 605 padding: var(--wui-spacing-s); 606 border-radius: var(--wui-border-radius-xxs); 607 transition: background 0.2s linear; 608 } 609 610 .details-container > wui-flex > button:hover { 611 background: var(--wui-color-gray-glass-002); 612 } 613 614 .details-content-container { 615 padding: var(--wui-spacing-1xs); 616 display: flex; 617 align-items: center; 618 justify-content: center; 619 } 620 621 .details-content-container > wui-flex { 622 width: 100%; 623 } 624 625 .details-row { 626 width: 100%; 627 padding: var(--wui-spacing-s) var(--wui-spacing-xl); 628 border-radius: var(--wui-border-radius-xxs); 629 background: var(--wui-color-gray-glass-002); 630 } 631`,D=function(t,e,o,i){var n,r=arguments.length,a=r<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,o):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,o,i);else for(var s=t.length-1;s>=0;s--)(n=t[s])&&(a=(r<3?n(a):r>3?n(e,o,a):n(e,o))||a);return r>3&&a&&Object.defineProperty(e,o,a),a};let R=class extends i.oi{constructor(){super(),this.unsubscribe=[],this.detailsOpen=!0,this.approvalTransaction=c.nY.state.approvalTransaction,this.swapTransaction=c.nY.state.swapTransaction,this.sourceToken=c.nY.state.sourceToken,this.sourceTokenAmount=c.nY.state.sourceTokenAmount??"",this.sourceTokenPriceInUSD=c.nY.state.sourceTokenPriceInUSD,this.toToken=c.nY.state.toToken,this.toTokenAmount=c.nY.state.toTokenAmount??"",this.toTokenPriceInUSD=c.nY.state.toTokenPriceInUSD,this.caipNetwork=l.R.state.activeCaipNetwork,this.balanceSymbol=s.AccountController.state.balanceSymbol,this.inputError=c.nY.state.inputError,this.loadingQuote=c.nY.state.loadingQuote,this.loadingApprovalTransaction=c.nY.state.loadingApprovalTransaction,this.loadingBuildTransaction=c.nY.state.loadingBuildTransaction,this.loadingTransaction=c.nY.state.loadingTransaction,this.unsubscribe.push(...[s.AccountController.subscribeKey("balanceSymbol",t=>{this.balanceSymbol!==t&&a.RouterController.goBack()}),l.R.subscribeKey("activeCaipNetwork",t=>{this.caipNetwork!==t&&(this.caipNetwork=t)}),c.nY.subscribe(t=>{this.approvalTransaction=t.approvalTransaction,this.swapTransaction=t.swapTransaction,this.sourceToken=t.sourceToken,this.toToken=t.toToken,this.toTokenPriceInUSD=t.toTokenPriceInUSD,this.sourceTokenAmount=t.sourceTokenAmount??"",this.toTokenAmount=t.toTokenAmount??"",this.inputError=t.inputError,t.inputError&&a.RouterController.goBack(),this.loadingQuote=t.loadingQuote,this.loadingApprovalTransaction=t.loadingApprovalTransaction,this.loadingBuildTransaction=t.loadingBuildTransaction,this.loadingTransaction=t.loadingTransaction})])}firstUpdated(){c.nY.getTransaction(),this.refreshTransaction()}disconnectedCallback(){this.unsubscribe.forEach(t=>t?.()),clearInterval(this.interval)}render(){return i.dy` 632 <wui-flex flexDirection="column" .padding=${["0","l","l","l"]} gap="s"> 633 ${this.templateSwap()} 634 </wui-flex> 635 `}refreshTransaction(){this.interval=setInterval(()=>{c.nY.getApprovalLoadingState()||c.nY.getTransaction()},1e4)}templateSwap(){let t=`${h.Hg.formatNumberToLocalString(parseFloat(this.sourceTokenAmount))} ${this.sourceToken?.symbol}`,e=`${h.Hg.formatNumberToLocalString(parseFloat(this.toTokenAmount))} ${this.toToken?.symbol}`,o=parseFloat(this.sourceTokenAmount)*this.sourceTokenPriceInUSD,n=parseFloat(this.toTokenAmount)*this.toTokenPriceInUSD,r=h.Hg.formatNumberToLocalString(o),a=h.Hg.formatNumberToLocalString(n),s=this.loadingQuote||this.loadingBuildTransaction||this.loadingTransaction||this.loadingApprovalTransaction;return i.dy` 636 <wui-flex flexDirection="column" alignItems="center" gap="l"> 637 <wui-flex class="preview-container" flexDirection="column" alignItems="flex-start" gap="l"> 638 <wui-flex 639 class="preview-token-details-container" 640 alignItems="center" 641 justifyContent="space-between" 642 gap="l" 643 > 644 <wui-flex flexDirection="column" alignItems="flex-start" gap="4xs"> 645 <wui-text variant="small-400" color="fg-150">Send</wui-text> 646 <wui-text variant="paragraph-400" color="fg-100">$${r}</wui-text> 647 </wui-flex> 648 <wui-token-button 649 flexDirection="row-reverse" 650 text=${t} 651 imageSrc=${this.sourceToken?.logoUri} 652 > 653 </wui-token-button>
653 654 </wui-flex> 655 <wui-icon name="recycleHorizontal" color="fg-200" size="md"></wui-icon> 656 <wui-flex 657 class="preview-token-details-container" 658 alignItems="center" 659 justifyContent="space-between" 660 gap="l" 661 > 662 <wui-flex flexDirection="column" alignItems="flex-start" gap="4xs"> 663 <wui-text variant="small-400" color="fg-150">Receive</wui-text> 664 <wui-text variant="paragraph-400" color="fg-100">$${a}</wui-text> 665 </wui-flex> 666 <wui-token-button 667 flexDirection="row-reverse" 668 text=${e} 669 imageSrc=${this.toToken?.logoUri} 670 > 671 </wui-token-button> 672 </wui-flex> 673 </wui-flex> 674 675 ${this.templateDetails()} 676 677 <wui-flex flexDirection="row" alignItems="center" justifyContent="center" gap="xs"> 678 <wui-icon size="sm" color="fg-200" name="infoCircle"></wui-icon> 679 <wui-text variant="small-400" color="fg-200">Review transaction carefully</wui-text> 680 </wui-flex> 681 682 <wui-flex 683 class="action-buttons-container" 684 flexDirection="row" 685 alignItems="center" 686 justifyContent="space-between" 687 gap="xs" 688 > 689 <wui-button 690 class="cancel-button" 691 fullWidth 692 size="lg" 693 borderRadius="xs" 694 variant="neutral" 695 @click=${this.onCancelTransaction.bind(this)} 696 > 697 <wui-text variant="paragraph-600" color="fg-200">Cancel</wui-text> 698 </wui-button> 699 <wui-button 700 class="action-button" 701 fullWidth 702 size="lg" 703 borderRadius="xs" 704 variant="main" 705 ?loading=${s} 706 ?disabled=${s} 707 @click=${this.onSendTransaction.bind(this)} 708 > 709 <wui-text variant="paragraph-600" color="inverse-100"> 710 ${this.actionButtonLabel()} 711 </wui-text> 712 </wui-button> 713 </wui-flex> 714 </wui-flex> 715 `}templateDetails(){return this.sourceToken&&this.toToken&&!this.inputError?i.dy`<w3m-swap-details .detailsOpen=${this.detailsOpen}></w3m-swap-details>`:null}actionButtonLabel(){return this.loadingApprovalTransaction?"Approving...":this.approvalTransaction?"Approve":"Swap"}onCancelTransaction(){a.RouterController.goBack()}onSendTransaction(){this.approvalTransaction?c.nY.sendTransactionForApproval(this.approvalTransaction):c.nY.sendTransactionForSwap(this.swapTransaction)}};R.styles=P,D([(0,n.SB)()],R.prototype,"interval",void 0),D([(0,n.SB)()],R.prototype,"detailsOpen",void 0),D([(0,n.SB)()],R.prototype,"approvalTransaction",void 0),D([(0,n.SB)()],R.prototype,"swapTransaction",void 0),D([(0,n.SB)()],R.prototype,"sourceToken",void 0),D([(0,n.SB)()],R.prototype,"sourceTokenAmount",void 0),D([(0,n.SB)()],R.prototype,"sourceTokenPriceInUSD",void 0),D([(0,n.SB)()],R.prototype,"toToken",void 0),D([(0,n.SB)()],R.prototype,"toTokenAmount",void 0),D([(0,n.SB)()],R.prototype,"toTokenPriceInUSD",void 0),D([(0,n.SB)()],R.prototype,"caipNetwork",void 0),D([(0,n.SB)()],R.prototype,"balanceSymbol",void 0),D([(0,n.SB)()],R.prototype,"inputError",void 0),D([(0,n.SB)()],R.prototype,"loadingQuote",void 0),D([(0,n.SB)()],R.prototype,"loadingApprovalTransaction",void 0),D([(0,n.SB)()],R.prototype,"loadingBuildTransaction",void 0),D([(0,n.SB)()],R.prototype,"loadingTransaction",void 0),R=D([(0,h.Mo)("w3m-swap-preview-view")],R),o(43722),o(5598),o(31059),o(79556),o(76630);var Y=o(24134),j=o(1512),E=o(25729),O=i.iv` 716 :host { 717 height: 60px; 718 min-height: 60px; 719 } 720 721 :host > wui-flex { 722 cursor: pointer; 723 height: 100%; 724 display: flex; 725 column-gap: var(--wui-spacing-s); 726 padding: var(--wui-spacing-xs); 727 padding-right: var(--wui-spacing-l); 728 width: 100%; 729 background-color: transparent; 730 border-radius: var(--wui-border-radius-xs); 731 color: var(--wui-color-fg-250); 732 transition: 733 background-color var(--wui-ease-out-power-1) var(--wui-duration-lg), 734 opacity var(--wui-ease-out-power-1) var(--wui-duration-lg); 735 will-change: background-color, opacity; 736 } 737 738 @media (hover: hover) and (pointer: fine) { 739 :host > wui-flex:hover { 740 background-color: var(--wui-color-gray-glass-002); 741 } 742 743 :host > wui-flex:active { 744 background-color: var(--wui-color-gray-glass-005); 745 } 746 } 747 748 :host([disabled]) > wui-flex { 749 opacity: 0.6; 750 } 751 752 :host([disabled]) > wui-flex:hover { 753 background-color: transparent; 754 } 755 756 :host > wui-flex > wui-flex { 757 flex: 1; 758 } 759 760 :host > wui-flex > wui-image, 761 :host > wui-flex > .token-item-image-placeholder { 762 width: 40px; 763 max-width: 40px; 764 height: 40px; 765 border-radius: var(--wui-border-radius-3xl); 766 position: relative; 767 } 768 769 :host > wui-flex > .token-item-image-placeholder { 770 display: flex; 771 align-items: center; 772 justify-content: center; 773 } 774 775 :host > wui-flex > wui-image::after, 776 :host > wui-flex > .token-item-image-placeholder::after { 777 position: absolute; 778 content: ''; 779 inset: 0; 780 box-shadow: inset 0 0 0 1px var(--wui-color-gray-glass-010); 781 border-radius: var(--wui-border-radius-l); 782 } 783 784 button > wui-icon-box[data-variant='square-blue'] { 785 border-radius: var(--wui-border-radius-3xs); 786 position: relative; 787 border: none; 788 width: 36px; 789 height: 36px; 790 } 791`,N=function(t,e,o,i){var n,r=arguments.length,a=r<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,o):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,o,i);else for(var s=t.length-1;s>=0;s--)(n=t[s])&&(a=(r<3?n(a):r>3?n(e,o,a):n(e,o))||a);return r>3&&a&&Object.defineProperty(e,o,a),a};let L=class extends i.oi{constructor(){super(),this.observer=new IntersectionObserver(()=>void 0),this.imageSrc=void 0,this.name=void 0,this.symbol=void 0,this.price=void 0,this.amount=void 0,this.visible=!1,this.imageError=!1,this.observer=new IntersectionObserver(t=>{t.forEach(t=>{t.isIntersecting?this.visible=!0:this.visible=!1})},{threshold:.1})}firstUpdated(){this.observer.observe(this)}disconnectedCallback(){this.observer.disconnect()}
791render(){if(!this.visible)return null;let t=this.amount&&this.price?r.C.multiply(this.price,this.amount)?.toFixed(3):null;return i.dy` 792 <wui-flex alignItems="center"> 793 ${this.visualTemplate()} 794 <wui-flex flexDirection="column" gap="3xs"> 795 <wui-flex justifyContent="space-between"> 796 <wui-text variant="paragraph-500" color="fg-100" lineClamp="1">${this.name}</wui-text> 797 ${t?i.dy` 798 <wui-text variant="paragraph-500" color="fg-100"> 799 $${j.H.formatNumberToLocalString(t,3)} 800 </wui-text> 801 `:null} 802 </wui-flex> 803 <wui-flex justifyContent="space-between"> 804 <wui-text variant="small-400" color="fg-200" lineClamp="1">${this.symbol}</wui-text> 805 ${this.amount?i.dy`<wui-text variant="small-400" color="fg-200"> 806 ${j.H.formatNumberToLocalString(this.amount,4)} 807 </wui-text>`:null} 808 </wui-flex> 809 </wui-flex> 810 </wui-flex> 811 `}visualTemplate(){return this.imageError?i.dy`<wui-flex class="token-item-image-placeholder"> 812 <wui-icon name="image" color="inherit"></wui-icon> 813 </wui-flex>`:this.imageSrc?i.dy`<wui-image 814 width="40" 815 height="40" 816 src=${this.imageSrc} 817 @onLoadError=${this.imageLoadError} 818 ></wui-image>`:null}imageLoadError(){this.imageError=!0}};L.styles=[Y.ET,Y.ZM,O],N([(0,n.Cb)()],L.prototype,"imageSrc",void 0),N([(0,n.Cb)()],L.prototype,"name",void 0),N([(0,n.Cb)()],L.prototype,"symbol",void 0),N([(0,n.Cb)()],L.prototype,"price",void 0),N([(0,n.Cb)()],L.prototype,"amount",void 0),N([(0,n.SB)()],L.prototype,"visible",void 0),N([(0,n.SB)()],L.prototype,"imageError",void 0),L=N([(0,E.M)("wui-token-list-item")],L);var U=i.iv` 819 :host { 820 --tokens-scroll--top-opacity: 0; 821 --tokens-scroll--bottom-opacity: 1; 822 --suggested-tokens-scroll--left-opacity: 0; 823 --suggested-tokens-scroll--right-opacity: 1; 824 } 825 826 :host > wui-flex:first-child { 827 overflow-y: hidden; 828 overflow-x: hidden; 829 scrollbar-width: none; 830 scrollbar-height: none; 831 } 832 833 :host > wui-flex:first-child::-webkit-scrollbar {
834 display: none; 835 } 836 837 wui-loading-hexagon { 838 position: absolute; 839 } 840 841 .suggested-tokens-container { 842 overflow-x: auto; 843 mask-image: linear-gradient( 844 to right, 845 rgba(0, 0, 0, calc(1 - var(--suggested-tokens-scroll--left-opacity))) 0px, 846 rgba(200, 200, 200, calc(1 - var(--suggested-tokens-scroll--left-opacity))) 1px, 847 black 50px, 848 black 90px, 849 black calc(100% - 90px), 850 black calc(100% - 50px), 851 rgba(155, 155, 155, calc(1 - var(--suggested-tokens-scroll--right-opacity))) calc(100% - 1px), 852 rgba(0, 0, 0, calc(1 - var(--suggested-tokens-scroll--right-opacity))) 100% 853 ); 854 } 855 856 .suggested-tokens-container::-webkit-scrollbar { 857 display: none; 858 } 859 860 .tokens-container { 861 border-top: 1px solid var(--wui-color-gray-glass-005); 862 height: 100%; 863 max-height: 390px; 864 } 865 866 .tokens { 867 width: 100%; 868 overflow-y: auto; 869 mask-image: linear-gradient( 870 to bottom, 871 rgba(0, 0, 0, calc(1 - var(--tokens-scroll--top-opacity))) 0px, 872 rgba(200, 200, 200, calc(1 - var(--tokens-scroll--top-opacity))) 1px, 873 black 50px, 874 black 90px, 875 black calc(100% - 90px), 876 black calc(100% - 50px), 877 rgba(155, 155, 155, calc(1 - var(--tokens-scroll--bottom-opacity))) calc(100% - 1px), 878 rgba(0, 0, 0, calc(1 - var(--tokens-scroll--bottom-opacity))) 100% 879 ); 880 } 881 882 .network-search-input, 883 .select-network-button { 884 height: 40px; 885 } 886 887 .select-network-button { 888 border: none; 889 display: flex; 890 flex-direction: row; 891 align-items: center; 892 justify-content: center; 893 gap: var(--wui-spacing-xs); 894 box-shadow: inset 0 0 0 1px var(--wui-color-gray-glass-005); 895 background-color: transparent; 896 border-radius: var(--wui-border-radius-xxs); 897 padding: var(--wui-spacing-xs); 898 align-items: center; 899 transition: background-color 0.2s linear; 900 } 901 902 .select-network-button:hover { 903 background-color: var(--wui-color-gray-glass-002); 904 } 905 906 .select-network-button > wui-image { 907 width: 26px; 908 height: 26px; 909 border-radius: var(--wui-border-radius-xs); 910 box-shadow: inset 0 0 0 1px var(--wui-color-gray-glass-010); 911 } 912`,z=function(t,e,o,i){var n,r=arguments.length,a=r<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,o):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,o,i);else for(var s=t.length-1;s>=0;s--)(n=t[s])&&(a=(r<3?n(a):r>3?n(e,o,a):n(e,o))||a);return r>3&&a&&Object.defineProperty(e,o,a),a};let M=class extends i.oi{constructor(){super(),this.unsubscribe=[],this.targetToken=a.RouterController.state.data?.target,this.sourceToken=c.nY.state.sourceToken,this.sourceTokenAmount=c.nY.state.sourceTokenAmount,this.toToken=c.nY.state.toToken,this.myTokensWithBalance=c.nY.state.myTokensWithBalance,this.popularTokens=c.nY.state.popularTokens,this.searchValue="",this.unsubscribe.push(...[c.nY.subscribe(t=>{this.sourceToken=t.sourceToken,this.toToken=t.toToken,this.myTokensWithBalance=t.myTokensWithBalance})])}updated(){let t=this.renderRoot?.querySelector(".suggested-tokens-container");t?.addEventListener("scroll",this.handleSuggestedTokensScroll.bind(this));let e=this.renderRoot?.querySelector(".tokens");e?.addEventListener("scroll",this.handleTokenListScroll.bind(this))}disconnectedCallback(){super.disconnectedCallback();let t=this.renderRoot?.querySelector(".suggested-tokens-container"),e=this.renderRoot?.querySelector(".tokens");t?.removeEventListener("scroll",this.handleSuggestedTokensScroll.bind(this)),e?.removeEventListener("scroll",this.handleTokenListScroll.bind(this)),clearInterval(this.interval)}render(){return i.dy` 913 <wui-flex flexDirection="column" gap="s"> 914 ${this.templateSearchInput()} ${this.templateSuggestedTokens()} ${this.templateTokens()} 915 </wui-flex> 916 `}onSelectToken(t){"sourceToken"===this.targetToken?c.nY.setSourceToken(t):(c.nY.setToToken(t),this.sourceToken&&this.sourceTokenAmount&&c.nY.swapTokens()),a.RouterController.goBack()}templateSearchInput(){return i.dy` 917 <wui-flex .padding=${["3xs","s","0","s"]} gap="xs"> 918 <wui-input-text 919 data-testid="swap-select-token-search-input" 920 class="network-search-input" 921 size="sm" 922 placeholder="Search token" 923 icon="search" 924 .value=${this.searchValue} 925 @inputChange=${this.onSearchInputChange.bind(this)} 926 ></wui-input-text> 927 </wui-flex> 928 `}templateTokens(){let t=this.myTokensWithBalance?Object.values(this.myTokensWithBalance):[],e=this.popularTokens?this.popularTokens:[],o=this.filterTokensWithText(t,this.searchValue),n=this.filterTokensWithText(e,this.searchValue);return i.dy` 929 <wui-flex class="tokens-container"> 930 <wui-flex class="tokens" .padding=${["0","s","s","s"]} flexDirection="column"> 931 ${o?.length>0?i.dy` 932 <wui-flex justifyContent="flex-start" padding="s"> 933 <wui-text variant="paragraph-500" color="fg-200">Your tokens</wui-text> 934 </wui-flex> 935 ${o.map(t=>{let e=t.symbol===this.sourceToken?.symbol||t.symbol===this.toToken?.symbol;return i.dy` 936 <wui-token-list-item 937 data-testid="swap-select-token-item-${t.symbol}" 938 name=${t.name} 939 ?disabled=${e} 940 symbol=${t.symbol} 941 price=${t?.price} 942 amount=${t?.quantity?.numeric} 943 imageSrc=${t.logoUri} 944 @click=${()=>{e||this.onSelectToken(t)}} 945 > 946 </wui-token-list-item> 947 `})} 948 `:null} 949 950 <wui-flex justifyContent="flex-start" padding="s"> 951 <wui-text variant="paragraph-500" color="fg-200">Tokens</wui-text> 952 </wui-flex> 953 ${n?.length>0?n.map(t=>i.dy` 954 <wui-token-list-item 955 data-testid="swap-select-token-item-${t.symbol}" 956 name=${t.name} 957 symbol=${t.symbol} 958 imageSrc=${t.logoUri} 959 @click=${()=>this.onSelectToken(t)} 960 > 961 </wui-token-list-item> 962 `):null} 963 </wui-flex> 964 </wui-flex> 965 `}templateSuggestedTokens(){let t=c.nY.state.suggestedTokens?c.nY.state.suggestedTokens.slice(0,8):null;return t?i.dy` 966 <wui-flex class="suggested-tokens-container" .padding=${["0","s","0","s"]} gap="xs"> 967 ${t.map(t=>i.dy` 968 <wui-token-button 969 text=${t.symbol} 970 imageSrc=${t.logoUri} 971 @click=${()=>this.onSelectToken(t)} 972 > 973 </wui-token-button>
973 974 `)} 975 </wui-flex> 976 `:null}onSearchInputChange(t){this.searchValue=t.detail}handleSuggestedTokensScroll(){let t=this.renderRoot?.querySelector(".suggested-tokens-container");t&&(t.style.setProperty("--suggested-tokens-scroll--left-opacity",h.kj.interpolate([0,100],[0,1],t.scrollLeft).toString()),t.style.setProperty("--suggested-tokens-scroll--right-opacity",h.kj.interpolate([0,100],[0,1],t.scrollWidth-t.scrollLeft-t.offsetWidth).toString()))}handleTokenListScroll(){let t=this.renderRoot?.querySelector(".tokens");t&&(t.style.setProperty("--tokens-scroll--top-opacity",h.kj.interpolate([0,100],[0,1],t.scrollTop).toString()),t.style.setProperty("--tokens-scroll--bottom-opacity",h.kj.interpolate([0,100],[0,1],t.scrollHeight-t.scrollTop-t.offsetHeight).toString()))}filterTokensWithText(t,e){return t.filter(t=>`${t.symbol} ${t.name} ${t.address}`.toLowerCase().includes(e.toLowerCase()))}};M.styles=U,z([(0,n.SB)()],M.prototype,"interval",void 0),z([(0,n.SB)()],M.prototype,"targetToken",void 0),z([(0,n.SB)()],M.prototype,"sourceToken",void 0),z([(0,n.SB)()],M.prototype,"sourceTokenAmount",void 0),z([(0,n.SB)()],M.prototype,"toToken",void 0),z([(0,n.SB)()],M.prototype,"myTokensWithBalance",void 0),z([(0,n.SB)()],M.prototype,"popularTokens",void 0),z([(0,n.SB)()],M.prototype,"searchValue",void 0),M=z([(0,h.Mo)("w3m-swap-select-token-view")],M)},71799:function(t,e,o){var i=o(19064),n=o(59662),r=o(77282),a=o(4511),s=o(83662),l=o(28740),c=i.iv` 977 :host { 978 width: 100%; 979 display: block; 980 } 981`,u=function(t,e,o,i){var n,r=arguments.length,a=r<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,o):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,o,i);else for(var s=t.length-1;s>=0;s--)(n=t[s])&&(a=(r<3?n(a):r>3?n(e,o,a):n(e,o))||a);return r>3&&a&&Object.defineProperty(e,o,a),a};let p=class extends i.oi{constructor(){super(),this.unsubscribe=[],this.text="",this.open=r.f.state.open,this.unsubscribe.push(a.RouterController.subscribeKey("view",()=>{r.f.hide()}),s.I.subscribeKey("open",t=>{t||r.f.hide()}),r.f.subscribeKey("open",t=>{this.open=t}))}disconnectedCallback(){this.unsubscribe.forEach(t=>t()),r.f.hide()}render(){return i.dy` 982 <div 983 @pointermove=${this.onMouseEnter.bind(this)} 984 @pointerleave=${this.onMouseLeave.bind(this)} 985 > 986 ${this.renderChildren()} 987 </div> 988 `}renderChildren(){return i.dy`<slot></slot> `}onMouseEnter(){let t=this.getBoundingClientRect();this.open||r.f.showTooltip({message:this.text,triggerRect:{width:t.width,height:t.height,left:t.left,top:t.top},variant:"shade"})}onMouseLeave(t){this.contains(t.relatedTarget)||r.f.hide()}};p.styles=[c],u([(0,n.Cb)()],p.prototype,"text",void 0),u([(0,n.SB)()],p.prototype,"open",void 0),u([(0,l.Mo)("w3m-tooltip-trigger")],p)},30553:function(t,e,o){var i=o(19064),n=o(59662),r=o(77282),a=o(28740);o(82100),o(85642),o(68390);var s=i.iv` 989 :host { 990 pointer-events: none; 991 } 992 993 :host > wui-flex { 994 display: var(--w3m-tooltip-display); 995 opacity: var(--w3m-tooltip-opacity); 996 padding: 9px var(--wui-spacing-s) 10px var(--wui-spacing-s); 997 border-radius: var(--wui-border-radius-xxs); 998 color: var(--wui-color-bg-100); 999 position: fixed; 1000 top: var(--w3m-tooltip-top); 1001 left: var(--w3m-tooltip-left); 1002 transform: translate(calc(-50% + var(--w3m-tooltip-parent-width)), calc(-100% - 8px)); 1003 max-width: calc(var(--w3m-modal-width) - var(--wui-spacing-xl)); 1004 transition: opacity 0.2s var(--wui-ease-out-power-2); 1005 will-change: opacity; 1006 } 1007 1008 :host([data-variant='shade']) > wui-flex { 1009 background-color: var(--wui-color-bg-150); 1010 border: 1px solid var(--wui-color-gray-glass-005); 1011 } 1012 1013 :host([data-variant='shade']) > wui-flex > wui-text { 1014 color: var(--wui-color-fg-150); 1015 } 1016 1017 :host([data-variant='fill']) > wui-flex { 1018 background-color: var(--wui-color-fg-100); 1019 border: none; 1020 } 1021 1022 wui-icon { 1023 position: absolute; 1024 width: 12px !important; 1025 height: 4px !important; 1026 color: var(--wui-color-bg-150); 1027 } 1028 1029 wui-icon[data-placement='top'] { 1030 bottom: 0px; 1031 left: 50%; 1032 transform: translate(-50%, 95%); 1033 } 1034 1035 wui-icon[data-placement='bottom'] { 1036 top: 0; 1037 left: 50%; 1038 transform: translate(-50%, -95%) rotate(180deg); 1039 } 1040 1041 wui-icon[data-placement='right'] { 1042 top: 50%; 1043 left: 0; 1044 transform: translate(-65%, -50%) rotate(90deg); 1045 } 1046 1047 wui-icon[data-placement='left'] { 1048 top: 50%; 1049 right: 0%; 1050 transform: translate(65%, -50%) rotate(270deg); 1051 } 1052`,l=function(t,e,o,i){var n,r=arguments.length,a=r<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,o):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,o,i);else for(var s=t.length-1;s>=0;s--)(n=t[s])&&(a=(r<3?n(a):r>3?n(e,o,a):n(e,o))||a);return r>3&&a&&Object.defineProperty(e,o,a),a};let c=class extends i.oi{constructor(){super(),this.unsubscribe=[],this.open=r.f.state.open,this.message=r.f.state.message,this.triggerRect=r.f.state.triggerRect,this.variant=r.f.state.variant,this.unsubscribe.push(...[r.f.subscribe(t=>{this.open=t.open,this.message=t.message,this.triggerRect=t.triggerRect,this.variant=t.variant})])}disconnectedCallback(){this.unsubscribe.forEach(t=>t())}render(){this.dataset.variant=this.variant;let t=this.triggerRect.top,e=this.triggerRect.left;return this.style.cssText=` 1053 --w3m-tooltip-top: ${t}px; 1054 --w3m-tooltip-left: ${e}px; 1055 --w3m-tooltip-parent-width: ${this.triggerRect.width/2}px; 1056 --w3m-tooltip-display: ${this.open?"flex":"none"}; 1057 --w3m-tooltip-opacity: ${this.open?1:0}; 1058 `,i.dy`<wui-flex> 1059 <wui-icon data-placement="top" color="fg-100" size="inherit" name="cursor"></wui-icon> 1060 <wui-text color="inherit" variant="small-500">${this.message}</wui-text> 1061 </wui-flex>`}};c.styles=[s],l([(0,n.SB)()],c.prototype,"open",void 0),l([(0,n.SB)()],c.prototype,"message",void 0),l([(0,n.SB)()],c.prototype,"triggerRect",void 0),l([(0,n.SB)()],c.prototype,"variant",void 0),l([(0,a.Mo)("w3m-tooltip"),(0,a.Mo)("w3m-tooltip")],c)},91833:function(t,e,o){o(22584)},22584:function(t,e,o){var i=o(19064),n=o(59662),r=o(25729),a=i.iv` 1062 :host { 1063 display: block; 1064 box-shadow: inset 0 0 0 1px var(--wui-color-gray-glass-005); 1065 background: linear-gradient( 1066 120deg, 1067 var(--wui-color-bg-200) 5%, 1068 var(--wui-color-bg-200) 48%, 1069 var(--wui-color-bg-300) 55%, 1070 var(--wui-color-bg-300) 60%, 1071 var(--wui-color-bg-300) calc(60% + 10px), 1072 var(--wui-color-bg-200) calc(60% + 12px), 1073 var(--wui-color-bg-200) 100% 1074 ); 1075 background-size: 250%; 1076 animation: shimmer 3s linear infinite reverse; 1077 } 1078 1079 :host([variant='light']) { 1080 background: linear-gradient( 1081 120deg, 1082 var(--wui-color-bg-150) 5%, 1083 var(--wui-color-bg-150) 48%, 1084 var(--wui-color-bg-200) 55%, 1085 var(--wui-color-bg-200) 60%, 1086 var(--wui-color-bg-200) calc(60% + 10px), 1087 var(--wui-color-bg-150) calc(60% + 12px), 1088 var(--wui-color-bg-150) 100% 1089 ); 1090 background-size: 250%; 1091 } 1092 1093 @keyframes shimmer { 1094 from { 1095 background-position: -250% 0; 1096 } 1097 to { 1098 background-position: 250% 0; 1099 } 1100 } 1101`,s=function(t,e,o,i){var n,r=arguments.length,a=r<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,o):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,o,i);else for(var s=t.length-1;s>=0;s--)(n=t[s])&&(a=(r<3?n(a):r>3?n(e,o,a):n(e,o))||a);return r>3&&a&&Object.defineProperty(e,o,a),a};let l=class extends i.oi{constructor(){super(...arguments),this.width="",this.height="",this.borderRadius="m",this.variant="default"}render(){return this.style.cssText=` 1102 width: ${this.width}; 1103 height: ${this.height}; 1104 border-radius: clamp(0px,var(--wui-border-radius-${this.borderRadius}), 40px); 1105 `,i.dy`<slot></slot>`}};l.styles=[a],s([(0,n.Cb)()],l.prototype,"width",void 0),s([(0,n.Cb)()],l.prototype,"height",void 0),s([(0,n.Cb)()],l.prototype,"borderRadius",void 0),s([(0,n.Cb)()],l.prototype,"variant",void 0),s([(0,r.M)("wui-shimmer")],l)}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.