PageSourceSearch

https://devconnect.org/_next/static/chunks/3856.b3b10409292b1429.js

js devconnect.org collected 2026-10-03 21:03:10 UTC 52,197 bytes, 976 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3856],{43856:(e,t,i)=>{i.r(t),i.d(t,{W3mSwapPreviewView:()=>E,W3mSwapSelectTokenView:()=>M,W3mSwapView:()=>D});var o=i(22707),n=i(71877),a=i(58692),r=i(6792),s=i(35728),l=i(12890),c=i(96060),u=i(85934),p=i(88950),d=i(77424),w=i(11862),h=i(21438);i(2080),i(21995),i(44949),i(97039);var g=i(98280),k=i(40818);i(74932),i(89803);let x=(0,o.AH)`
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`;var b=function(e,t,i,o){var n,a=arguments.length,r=a<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,i):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,i,o);else for(var s=e.length-1;s>=0;s--)(n=e[s])&&(r=(a<3?n(r):a>3?n(t,i,r):n(t,i))||r);return a>3&&r&&Object.defineProperty(t,i,r),r};let m=k.oU.CONVERT_SLIPPAGE_TOLERANCE,f=class extends o.WF{constructor(){super(),this.unsubscribe=[],this.networkName=l.W.state.activeCaipNetwork?.name,this.detailsOpen=!1,this.sourceToken=c.GN.state.sourceToken,this.toToken=c.GN.state.toToken,this.toTokenAmount=c.GN.state.toTokenAmount,this.sourceTokenPriceInUSD=c.GN.state.sourceTokenPriceInUSD,this.toTokenPriceInUSD=c.GN.state.toTokenPriceInUSD,this.priceImpact=c.GN.state.priceImpact,this.maxSlippage=c.GN.state.maxSlippage,this.networkTokenSymbol=c.GN.state.networkTokenSymbol,this.inputError=c.GN.state.inputError,this.unsubscribe.push(c.GN.subscribe(e=>{this.sourceToken=e.sourceToken,this.toToken=e.toToken,this.toTokenAmount=e.toTokenAmount,this.priceImpact=e.priceImpact,this.maxSlippage=e.maxSlippage,this.sourceTokenPriceInUSD=e.sourceTokenPriceInUSD,this.toTokenPriceInUSD=e.toTokenPriceInUSD,this.inputError=e.inputError}))}render(){let e=this.toTokenAmount&&this.maxSlippage?a.S.bigNumber(this.toTokenAmount).minus(this.maxSlippage).toString():null;if(!this.sourceToken||!this.toToken||this.inputError)return null;let t=this.sourceTokenPriceInUSD&&this.toTokenPriceInUSD?1/this.toTokenPriceInUSD*this.sourceTokenPriceInUSD:0;return(0,o.qy)`
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.Zv.formatNumberToLocalString(t,3)}
57                  ${this.toToken.symbol}
58                </wui-text>
59                <wui-text variant="small-400" color="fg-200">
60                  $${h.Zv.formatNumberToLocalString(this.sourceTokenPriceInUSD)}
61                </wui-text>
62              </wui-flex>
63              <wui-icon name="chevronBottom"></wui-icon>
64            </wui-flex>
65          </button>
66          ${this.detailsOpen?(0,o.qy)`
67                <wui-flex flexDirection="column" gap="xs" class="details-content-container">
68                  ${this.priceImpact?(0,o.qy)` <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.Zv.formatNumberToLocalString(this.priceImpact,3)}%
87                            </wui-text>
88                          </wui-flex>
89                        </wui-flex>
90                      </wui-flex>`:null}
91                  ${this.maxSlippage&&this.sourceToken.symbol?(0,o.qy)`<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. ${e?`Transaction will be reversed if you receive less than ${h.Zv.formatNumberToLocalString(e,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.Zv.formatNumberToLocalString(this.maxSlippage,6)}
110                              ${this.toToken.symbol} ${m}%
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}};f.styles=[x],b([(0,n.wk)()],f.prototype,"networkName",void 0),b([(0,n.MZ)()],f.prototype,"detailsOpen",void 0),b([(0,n.wk)()],f.prototype,"sourceToken",void 0),b([(0,n.wk)()],f.prototype,"toToken",void 0),b([(0,n.wk)()],f.prototype,"toTokenAmount",void 0),b([(0,n.wk)()],f.prototype,"sourceTokenPriceInUSD",void 0),b([(0,n.wk)()],f.prototype,"toTokenPriceInUSD",void 0),b([(0,n.wk)()],f.prototype,"priceImpact",void 0),b([(0,n.wk)()],f.prototype,"maxSlippage",void 0),b([(0,n.wk)()],f.prototype,"networkTokenSymbol",void 0),b([(0,n.wk)()],f.prototype,"inputError",void 0),f=b([(0,h.EM)("w3m-swap-details")],f),i(56375);let v=(0,o.AH)`
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`;var y=function(e,t,i,o){var n,a=arguments.length,r=a<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,i):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,i,o);else for(var s=e.length-1;s>=0;s--)(n=e[s])&&(r=(a<3?n(r):a>3?n(t,i,r):n(t,i))||r);return a>3&&r&&Object.defineProperty(t,i,r),r};let T=class extends o.WF{constructor(){super(...arguments),this.target="sourceToken"}render(){return(0,o.qy)`
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(0,o.qy)`
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    `}};T.styles=[v],y([(0,n.MZ)()],T.prototype,"target",void 0),T=y([(0,h.EM)("w3m-swap-input-skeleton")],T);let S={numericInputKeyDown(e,t,i){let o=e.metaKey||e.ctrlKey,n=e.key,a=n.toLocaleLowerCase(),r=","===n,s="."===n,l=n>="0"&&n<="9";o||"a"!==a&&"c"!==a&&"v"!==a&&"x"!==a||e.preventDefault(),"0"!==t||r||s||"0"!==n||e.preventDefault(),"0"===t&&l&&(i(n),e.preventDefault()),(r||s)&&(t||(i("0."),e.preventDefault()),(t?.includes(".")||t?.includes(","))&&e.preventDefault()),l||["Backspace","Meta","Ctrl","a","A","c","C","x","X","v","V","ArrowLeft","ArrowRight","Tab"].includes(n)||s||r||e.preventDefault()}};i(51636);let N=(0,o.AH)`
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`;var $=function(e,t,i,o){var n,a=arguments.length,r=a<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,i):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,i,o);else for(var s=e.length-1;s>=0;s--)(n=e[s])&&(r=(a<3?n(r):a>3?n(t,i,r):n(t,i))||r);return a>3&&r&&Object.defineProperty(t,i,r),r};let I=class extends o.WF{constructor(){super(...arguments),this.focused=!1,this.price=0,this.target="sourceToken",this.onSetAmount=null,this.onSetMaxValue=null}render(){let e=this.marketValue||"0",t=a.S.bigNumber(e).gt("0");return(0,o.qy)`
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            ${t?`$${h.Zv.formatNumberToLocalString(this.marketValue,2)}`:null}
312          </wui-text>
313        </wui-flex>
314        ${this.templateTokenSelectButton()}
315      </wui-flex>
316    `}handleKeydown(e){return S.numericInputKeyDown(e,this.value,e=>this.onSetAmount?.(this.target,e))}dispatchInputChangeEvent(e){if(!this.onSetAmount)return;let t=e.target.value.replace(/[^0-9.]/gu,"");","===t||"."===t?this.onSetAmount(this.target,"0."):t.endsWith(",")?this.onSetAmount(this.target,t.replace(",",".")):this.onSetAmount(this.target,t)}setMaxValueToInput(){this.onSetMaxValue?.(this.target,this.balance)}templateTokenSelectButton(){return this.token?(0,o.qy)`
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    `:(0,o.qy)` <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 e=a.S.multiply(this.balance,this.price),t=!!e&&e?.gt(5e-5);return(0,o.qy)`
342      ${t?(0,o.qy)`<wui-text variant="small-400" color="fg-200">
343            ${h.Zv.formatNumberToLocalString(this.balance,2)}
344          </wui-text>`:null}
345      ${"sourceToken"===this.target?this.tokenActionButtonTemplate(t):null}
346    `}tokenActionButtonTemplate(e){return e?(0,o.qy)` <button class="max-value-button" @click=${this.setMaxValueToInput.bind(this)}>
347        <wui-text color="accent-100" variant="small-600">Max</wui-text>
348      </button>`:(0,o.qy)` <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(e){this.focused=e}onSelectToken(){d.E.sendEvent({type:"track",event:"CLICK_SELECT_TOKEN_TO_SWAP"}),r.I.push("SwapSelectToken",{target:this.target})}
350onBuyToken(){r.I.push("OnRampProviders")}};I.styles=[N],$([(0,n.MZ)()],I.prototype,"focused",void 0),$([(0,n.MZ)()],I.prototype,"balance",void 0),$([(0,n.MZ)()],I.prototype,"value",void 0),$([(0,n.MZ)()],I.prototype,"price",void 0),$([(0,n.MZ)()],I.prototype,"marketValue",void 0),$([(0,n.MZ)()],I.prototype,"disabled",void 0),$([(0,n.MZ)()],I.prototype,"target",void 0),$([(0,n.MZ)()],I.prototype,"token",void 0),$([(0,n.MZ)()],I.prototype,"onSetAmount",void 0),$([(0,n.MZ)()],I.prototype,"onSetMaxValue",void 0),I=$([(0,h.EM)("w3m-swap-input")],I);let A=(0,o.AH)`
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`;var P=function(e,t,i,o){var n,a=arguments.length,r=a<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,i):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,i,o);else for(var s=e.length-1;s>=0;s--)(n=e[s])&&(r=(a<3?n(r):a>3?n(t,i,r):n(t,i))||r);return a>3&&r&&Object.defineProperty(t,i,r),r};let D=class extends o.WF{constructor(){super(),this.unsubscribe=[],this.initialParams=r.I.state.data?.swap,this.detailsOpen=!1,this.caipAddress=s.U.state.caipAddress,this.caipNetworkId=l.W.state.activeCaipNetwork?.caipNetworkId,this.initialized=c.GN.state.initialized,this.loadingQuote=c.GN.state.loadingQuote,this.loadingPrices=c.GN.state.loadingPrices,this.loadingTransaction=c.GN.state.loadingTransaction,this.sourceToken=c.GN.state.sourceToken,this.sourceTokenAmount=c.GN.state.sourceTokenAmount,this.sourceTokenPriceInUSD=c.GN.state.sourceTokenPriceInUSD,this.toToken=c.GN.state.toToken,this.toTokenAmount=c.GN.state.toTokenAmount,this.toTokenPriceInUSD=c.GN.state.toTokenPriceInUSD,this.inputError=c.GN.state.inputError,this.fetchError=c.GN.state.fetchError,this.lastTokenPriceUpdate=0,this.minTokenPriceUpdateInterval=1e4,this.visibilityChangeHandler=()=>{document?.hidden?(clearInterval(this.interval),this.interval=void 0):this.startTokenPriceInterval()},this.startTokenPriceInterval=()=>{this.interval&&Date.now()-this.lastTokenPriceUpdate<this.minTokenPriceUpdateInterval||(this.lastTokenPriceUpdate&&Date.now()-this.lastTokenPriceUpdate>this.minTokenPriceUpdateInterval&&this.fetchTokensAndValues(),clearInterval(this.interval),this.interval=setInterval(()=>{this.fetchTokensAndValues()},this.minTokenPriceUpdateInterval))},this.watchTokensAndValues=()=>{this.sourceToken&&this.toToken&&(this.subscribeToVisibilityChange(),this.startTokenPriceInterval())},this.onDebouncedGetSwapCalldata=u.w.debounce(async()=>{await c.GN.swapTokens()},200),l.W.subscribeKey("activeCaipNetwork",e=>this.onCaipNetworkChange({newCaipNetwork:e,resetSwapState:!0,initializeSwapState:!1})),s.U.subscribeKey("caipAddress",e=>this.onCaipAddressChange({newCaipAddress:e,resetSwapState:!0,initializeSwapState:!1})),this.unsubscribe.push(l.W.subscribeKey("activeCaipNetwork",e=>this.onCaipNetworkChange({newCaipNetwork:e,resetSwapState:!1,initializeSwapState:!0})),s.U.subscribeKey("caipAddress",e=>this.onCaipAddressChange({newCaipAddress:e,resetSwapState:!1,initializeSwapState:!0})),p.W.subscribeKey("open",e=>{e||c.GN.resetState()}),r.I.subscribeKey("view",e=>{e.includes("Swap")||c.GN.resetValues()}),c.GN.subscribe(e=>{this.initialized=e.initialized,this.loadingQuote=e.loadingQuote,this.loadingPrices=e.loadingPrices,this.loadingTransaction=e.loadingTransaction,this.sourceToken=e.sourceToken,this.sourceTokenAmount=e.sourceTokenAmount,this.sourceTokenPriceInUSD=e.sourceTokenPriceInUSD,this.toToken=e.toToken,this.toTokenAmount=e.toTokenAmount,this.toTokenPriceInUSD=e.toTokenPriceInUSD,this.inputError=e.inputError,this.fetchError=e.fetchError,e.
446sourceToken&&e.toToken&&this.watchTokensAndValues()}))}async firstUpdated(){c.GN.initializeState(),this.watchTokensAndValues(),await this.handleSwapParameters()}disconnectedCallback(){this.unsubscribe.forEach(e=>e?.()),clearInterval(this.interval),document?.removeEventListener("visibilitychange",this.visibilityChangeHandler)}render(){return(0,o.qy)`
447      <wui-flex flexDirection="column" .padding=${["0","l","l","l"]} gap="s">
448        ${this.initialized?this.templateSwap():this.templateLoading()}
449      </wui-flex>
450    `}subscribeToVisibilityChange(){document?.removeEventListener("visibilitychange",this.visibilityChangeHandler),document?.addEventListener("visibilitychange",this.visibilityChangeHandler)}fetchTokensAndValues(){c.GN.getNetworkTokenPrice(),c.GN.getMyTokensWithBalance(),c.GN.swapTokens(),this.lastTokenPriceUpdate=Date.now()}templateSwap(){return(0,o.qy)`
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(0,o.qy)`
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(0,o.qy)`
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(e,t){let i=c.GN.state.myTokensWithBalance?.find(e=>e?.address===t?.address),n="toToken"===e?this.toTokenAmount:this.sourceTokenAmount,r="toToken"===e?this.toTokenPriceInUSD:this.sourceTokenPriceInUSD,s=a.S.parseLocalStringToNumber(n)*r;return(0,o.qy)`<w3m-swap-input
474      .value=${"toToken"===e?this.toTokenAmount:this.sourceTokenAmount}
475      .disabled=${"toToken"===e}
476      .onSetAmount=${this.handleChangeAmount.bind(this)}
477      target=${e}
478      .token=${t}
479      .balance=${i?.quantity?.numeric}
480      .price=${i?.price}
481      .marketValue=${s}
482      .onSetMaxValue=${this.onSetMaxValue.bind(this)}
483    ></w3m-swap-input>`}onSetMaxValue(e,t){let i=a.S.bigNumber(t||"0");this.handleChangeAmount(e,i.gt(0)?i.toFixed(20):"0")}templateDetails(){return this.sourceToken&&this.toToken&&!this.inputError?(0,o.qy)`<w3m-swap-details .detailsOpen=${this.detailsOpen}></w3m-swap-details>`:null}handleChangeAmount(e,t){c.GN.clearError(),"sourceToken"===e?c.GN.setSourceTokenAmount(t):c.GN.setToTokenAmount(t),this.onDebouncedGetSwapCalldata()}templateActionButton(){let e=!this.toToken||!this.sourceToken,t=!this.sourceTokenAmount,i=this.loadingQuote||this.loadingPrices||this.loadingTransaction,n=i||e||t||this.inputError;return(0,o.qy)` <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=${e?"neutral":"main"}
491        .loading=${i}
492        .disabled=${n}
493        @click=${this.onSwapPreview.bind(this)}
494      >
495        ${this.actionButtonLabel()}
496      </wui-button>
497    </wui-flex>`}onSwitchTokens(){c.GN.switchTokens()}async onSwapPreview(){this.fetchError&&await c.GN.swapTokens(),d.E.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:(0,w.lj)(l.W.state.activeChain)===g.Vl.ACCOUNT_TYPES.SMART_ACCOUNT}}),r.I.push("SwapPreview")}async handleSwapParameters(){if(this.initialParams){if(!c.GN.state.initialized){let e=new Promise(e=>{let t=c.GN.subscribeKey("initialized",i=>{i&&(t?.(),e())})});await e}await this.setSwapParameters(this.initialParams)}}async setSwapParameters({amount:e,fromToken:t,toToken:i}){if(!c.GN.state.tokens||!c.GN.state.myTokensWithBalance){let e=new Promise(e=>{let t=c.GN.subscribeKey("myTokensWithBalance",i=>{i&&i.length>0&&(t?.(),e())});setTimeout(()=>{t?.(),e()},5e3)});await e}
497let o=[...c.GN.state.tokens||[],...c.GN.state.myTokensWithBalance||[]];if(t){let e=o.find(e=>e.symbol.toLowerCase()===t.toLowerCase());e&&c.GN.setSourceToken(e)}if(i){let e=o.find(e=>e.symbol.toLowerCase()===i.toLowerCase());e&&c.GN.setToToken(e)}e&&!isNaN(Number(e))&&c.GN.setSourceTokenAmount(e)}onCaipAddressChange({newCaipAddress:e,resetSwapState:t,initializeSwapState:i}){this.caipAddress!==e&&(this.caipAddress=e,t&&c.GN.resetState(),i&&c.GN.initializeState())}onCaipNetworkChange({newCaipNetwork:e,resetSwapState:t,initializeSwapState:i}){this.caipNetworkId!==e?.caipNetworkId&&(this.caipNetworkId=e?.caipNetworkId,t&&c.GN.resetState(),i&&c.GN.initializeState())}};D.styles=A,P([(0,n.MZ)({type:Object})],D.prototype,"initialParams",void 0),P([(0,n.wk)()],D.prototype,"interval",void 0),P([(0,n.wk)()],D.prototype,"detailsOpen",void 0),P([(0,n.wk)()],D.prototype,"caipAddress",void 0),P([(0,n.wk)()],D.prototype,"caipNetworkId",void 0),P([(0,n.wk)()],D.prototype,"initialized",void 0),P([(0,n.wk)()],D.prototype,"loadingQuote",void 0),P([(0,n.wk)()],D.prototype,"loadingPrices",void 0),P([(0,n.wk)()],D.prototype,"loadingTransaction",void 0),P([(0,n.wk)()],D.prototype,"sourceToken",void 0),P([(0,n.wk)()],D.prototype,"sourceTokenAmount",void 0),P([(0,n.wk)()],D.prototype,"sourceTokenPriceInUSD",void 0),P([(0,n.wk)()],D.prototype,"toToken",void 0),P([(0,n.wk)()],D.prototype,"toTokenAmount",void 0),P([(0,n.wk)()],D.prototype,"toTokenPriceInUSD",void 0),P([(0,n.wk)()],D.prototype,"inputError",void 0),P([(0,n.wk)()],D.prototype,"fetchError",void 0),P([(0,n.wk)()],D.prototype,"lastTokenPriceUpdate",void 0),D=P([(0,h.EM)("w3m-swap-view")],D);let C=(0,o.AH)`
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`;var G=function(e,t,i,o){var n,a=arguments.length,r=a<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,i):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,i,o);else for(var s=e.length-1;s>=0;s--)(n=e[s])&&(r=(a<3?n(r):a>3?n(t,i,r):n(t,i))||r);return a>3&&r&&Object.defineProperty(t,i,r),r};let E=class extends o.WF{constructor(){super(),this.unsubscribe=[],this.detailsOpen=!0,this.approvalTransaction=c.GN.state.approvalTransaction,this.swapTransaction=c.GN.state.swapTransaction,this.sourceToken=c.GN.state.sourceToken,this.sourceTokenAmount=c.GN.state.sourceTokenAmount??"",this.sourceTokenPriceInUSD=c.GN.state.sourceTokenPriceInUSD,this.toToken=c.GN.state.toToken,this.toTokenAmount=c.GN.state.toTokenAmount??"",this.toTokenPriceInUSD=c.GN.state.toTokenPriceInUSD,this.caipNetwork=l.W.state.activeCaipNetwork,this.balanceSymbol=s.U.state.balanceSymbol,this.inputError=c.GN.state.inputError,this.loadingQuote=c.GN.state.loadingQuote,this.loadingApprovalTransaction=c.GN.state.loadingApprovalTransaction,this.loadingBuildTransaction=c.GN.state.loadingBuildTransaction,this.loadingTransaction=c.GN.state.loadingTransaction,this.unsubscribe.push(s.U.subscribeKey("balanceSymbol",e=>{this.balanceSymbol!==e&&r.I.goBack()}),l.W.subscribeKey("activeCaipNetwork",e=>{this.caipNetwork!==e&&(this.caipNetwork=e)}),c.GN.subscribe(e=>{this.approvalTransaction=e.approvalTransaction,this.swapTransaction=e.swapTransaction,this.sourceToken=e.sourceToken,this.toToken=e.toToken,this.toTokenPriceInUSD=e.toTokenPriceInUSD,this.sourceTokenAmount=e.sourceTokenAmount??"",this.toTokenAmount=e.toTokenAmount??"",this.inputError=e.inputError,e.inputError&&r.I.goBack(),this.loadingQuote=e.loadingQuote,this.loadingApprovalTransaction=e.loadingApprovalTransaction,this.loadingBuildTransaction=e.loadingBuildTransaction,this.loadingTransaction=e.loadingTransaction}))}firstUpdated(){c.GN.getTransaction(),this.refreshTransaction()}
631disconnectedCallback(){this.unsubscribe.forEach(e=>e?.()),clearInterval(this.interval)}render(){return(0,o.qy)`
632      <wui-flex flexDirection="column" .padding=${["0","l","l","l"]} gap="s">
633        ${this.templateSwap()}
634      </wui-flex>
635    `}refreshTransaction(){this.interval=setInterval(()=>{c.GN.getApprovalLoadingState()||c.GN.getTransaction()},1e4)}templateSwap(){let e=`${h.Zv.formatNumberToLocalString(parseFloat(this.sourceTokenAmount))} ${this.sourceToken?.symbol}`,t=`${h.Zv.formatNumberToLocalString(parseFloat(this.toTokenAmount))} ${this.toToken?.symbol}`,i=parseFloat(this.sourceTokenAmount)*this.sourceTokenPriceInUSD,n=parseFloat(this.toTokenAmount)*this.toTokenPriceInUSD,a=h.Zv.formatNumberToLocalString(i),r=h.Zv.formatNumberToLocalString(n),s=this.loadingQuote||this.loadingBuildTransaction||this.loadingTransaction||this.loadingApprovalTransaction;return(0,o.qy)`
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">$${a}</wui-text>
647            </wui-flex>
648            <wui-token-button
649              flexDirection="row-reverse"
650              text=${e}
651              imageSrc=${this.sourceToken?.logoUri}
652            >
653            </wui-token-button>
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">$${r}</wui-text>
665            </wui-flex>
666            <wui-token-button
667              flexDirection="row-reverse"
668              text=${t}
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?(0,o.qy)`<w3m-swap-details .detailsOpen=${this.detailsOpen}></w3m-swap-details>`:null}actionButtonLabel(){return this.loadingApprovalTransaction?"Approving...":this.approvalTransaction?"Approve":"Swap"}onCancelTransaction(){r.I.goBack()}onSendTransaction(){this.approvalTransaction?c.GN.sendTransactionForApproval(this.approvalTransaction):c.GN.sendTransactionForSwap(this.swapTransaction)}};E.styles=C,G([(0,n.wk)()],E.prototype,"interval",void 0),G([(0,n.wk)()],E.prototype,"detailsOpen",void 0),G([(0,n.wk)()],E.prototype,"approvalTransaction",void 0),G([(0,n.wk)()],E.prototype,"swapTransaction",void 0),G([(0,n.wk)()],E.prototype,"sourceToken",void 0),G([(0,n.wk)()],E.prototype,"sourceTokenAmount",void 0),G([(0,n.wk)()],E.prototype,"sourceTokenPriceInUSD",void 0),G([(0,n.wk)()],E.prototype,"toToken",void 0),G([(0,n.wk)()],E.prototype,"toTokenAmount",void 0),G([(0,n.wk)()],E.prototype,"toTokenPriceInUSD",void 0),G([(0,n.wk)()],E.prototype,"caipNetwork",void 0),G([(0,n.wk)()],E.prototype,"balanceSymbol",void 0),G([(0,n.wk)()],E.prototype,"inputError",void 0),G([(0,n.wk)()],E.prototype,"loadingQuote",void 0),G([(0,n.wk)()],E.prototype,"loadingApprovalTransaction",void 0),G([(0,n.wk)()],E.prototype,"loadingBuildTransaction",void 0),G([(0,n.wk)()],E.prototype,"loadingTransaction",void 0),E=G([(0,h.EM)("w3m-swap-preview-view")],E),i(66504),i(85219),i(2657),i(67327),i(18089);var U=i(12248),j=i(35813),L=i(64859);let q=(0,o.AH)`
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`;var B=function(e,t,i,o){var n,a=arguments.length,r=a<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,i):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,i,o);else for(var s=e.length-1;s>=0;s--)(n=e[s])&&(r=(a<3?n(r):a>3?n(t,i,r):n(t,i))||r);return a>3&&r&&Object.defineProperty(t,i,r),r};let O=class extends o.WF{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(e=>
791{e.forEach(e=>{e.isIntersecting?this.visible=!0:this.visible=!1})},{threshold:.1})}firstUpdated(){this.observer.observe(this)}disconnectedCallback(){this.observer.disconnect()}render(){if(!this.visible)return null;let e=this.amount&&this.price?a.S.multiply(this.price,this.amount)?.toFixed(3):null;return(0,o.qy)`
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            ${e?(0,o.qy)`
798                  <wui-text variant="paragraph-500" color="fg-100">
799                    $${j.Z.formatNumberToLocalString(e,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?(0,o.qy)`<wui-text variant="small-400" color="fg-200">
806                  ${j.Z.formatNumberToLocalString(this.amount,3)}
807                </wui-text>`:null}
808          </wui-flex>
809        </wui-flex>
810      </wui-flex>
811    `}visualTemplate(){return this.imageError?(0,o.qy)`<wui-flex class="token-item-image-placeholder">
812        <wui-icon name="image" color="inherit"></wui-icon>
813      </wui-flex>`:this.imageSrc?(0,o.qy)`<wui-image
814        width="40"
815        height="40"
816        src=${this.imageSrc}
817        @onLoadError=${this.imageLoadError}
818      ></wui-image>`:null}imageLoadError(){this.imageError=!0}};O.styles=[U.W5,U.fD,q],B([(0,n.MZ)()],O.prototype,"imageSrc",void 0),B([(0,n.MZ)()],O.prototype,"name",void 0),B([(0,n.MZ)()],O.prototype,"symbol",void 0),B([(0,n.MZ)()],O.prototype,"price",void 0),B([(0,n.MZ)()],O.prototype,"amount",void 0),B([(0,n.wk)()],O.prototype,"visible",void 0),B([(0,n.wk)()],O.prototype,"imageError",void 0),O=B([(0,L.E)("wui-token-list-item")],O);let R=(0,o.AH)`
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`;var W=function(e,t,i,o){var n,a=arguments.length,r=a<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,i):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,i,o);else for(var s=e.length-1;s>=0;s--)(n=e[s])&&(r=(a<3?n(r):a>3?n(t,i,r):n(t,i))||r);return a>3&&r&&Object.defineProperty(t,i,r),r};let M=class extends o.WF{constructor(){super(),this.unsubscribe=[],this.targetToken=r.I.state.data?.target,this.sourceToken=c.GN.state.sourceToken,this.sourceTokenAmount=c.GN.state.sourceTokenAmount,this.toToken=c.GN.state.toToken,this.myTokensWithBalance=c.GN.state.myTokensWithBalance,this.popularTokens=c.GN.state.popularTokens,this.searchValue="",this.unsubscribe.push(c.GN.subscribe(e=>{this.sourceToken=e.sourceToken,this.toToken=e.toToken,this.myTokensWithBalance=e.myTokensWithBalance}))}updated(){let e=this.renderRoot?.querySelector(".suggested-tokens-container");e?.addEventListener("scroll",this.handleSuggestedTokensScroll.bind(this));let t=this.renderRoot?.querySelector(".tokens");t?.addEventListener("scroll",this.handleTokenListScroll.bind(this))}disconnectedCallback(){super.disconnectedCallback();let e=this.renderRoot?.querySelector(".suggested-tokens-container"),t=this.renderRoot?.querySelector(".tokens");e?.removeEventListener("scroll",this.handleSuggestedTokensScroll.bind(this)),t?.removeEventListener("scroll",this.handleTokenListScroll.bind(this)),clearInterval(this.interval)}render(){return(0,o.qy)`
913      <wui-flex flexDirection="column" gap="s">
914        ${this.templateSearchInput()} ${this.templateSuggestedTokens()} ${this.templateTokens()}
915      </wui-flex>
916    `}onSelectToken(e){"sourceToken"===this.targetToken?c.GN.setSourceToken(e):(c.GN.setToToken(e),this.sourceToken&&this.sourceTokenAmount&&c.GN.swapTokens()),r.I.goBack()}templateSearchInput(){return(0,o.qy)`
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 e=this.myTokensWithBalance?Object.values(this.myTokensWithBalance):[],t=this.popularTokens?this.popularTokens:[],i=this.filterTokensWithText(e,this.searchValue),n=this.filterTokensWithText(t,this.searchValue);return(0,o.qy)`
929      <wui-flex class="tokens-container">
930        <wui-flex class="tokens" .padding=${["0","s","s","s"]} flexDirection="column">
931          ${i?.length>0?(0,o.qy)`
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                ${i.map(e=>{let t=e.symbol===this.sourceToken?.symbol||e.symbol===this.toToken?.symbol;return(0,o.qy)`
936                    <wui-token-list-item
937                      data-testid="swap-select-token-item-${e.symbol}"
938                      name=${e.name}
939                      ?disabled=${t}
940                      symbol=${e.symbol}
941                      price=${e?.price}
942                      amount=${e?.quantity?.numeric}
943                      imageSrc=${e.logoUri}
944                      @click=${()=>{t||this.onSelectToken(e)}}
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(e=>(0,o.qy)`
954                  <wui-token-list-item
955                    data-testid="swap-select-token-item-${e.symbol}"
956                    name=${e.name}
957                    symbol=${e.symbol}
958                    imageSrc=${e.logoUri}
959                    @click=${()=>this.onSelectToken(e)}
960                  >
961                  </wui-token-list-item>
962                `):null}
963        </wui-flex>
964      </wui-flex>
965    `}templateSuggestedTokens(){let e=c.GN.state.suggestedTokens?c.GN.state.suggestedTokens.slice(0,8):null;return e?(0,o.qy)`
966      <wui-flex class="suggested-tokens-container" .padding=${["0","s","0","s"]} gap="xs">
967        ${e.map(e=>(0,o.qy)`
968            <wui-token-button
969              text=${e.symbol}
970              imageSrc=${e.logoUri}
971              @click=${()=>this.onSelectToken(e)}
972            >
973            </wui-token-button>
973
974          `)}
975      </wui-flex>
976    `:null}onSearchInputChange(e){this.searchValue=e.detail}handleSuggestedTokensScroll(){let e=this.renderRoot?.querySelector(".suggested-tokens-container");e&&(e.style.setProperty("--suggested-tokens-scroll--left-opacity",h.z8.interpolate([0,100],[0,1],e.scrollLeft).toString()),e.style.setProperty("--suggested-tokens-scroll--right-opacity",h.z8.interpolate([0,100],[0,1],e.scrollWidth-e.scrollLeft-e.offsetWidth).toString()))}handleTokenListScroll(){let e=this.renderRoot?.querySelector(".tokens");e&&(e.style.setProperty("--tokens-scroll--top-opacity",h.z8.interpolate([0,100],[0,1],e.scrollTop).toString()),e.style.setProperty("--tokens-scroll--bottom-opacity",h.z8.interpolate([0,100],[0,1],e.scrollHeight-e.scrollTop-e.offsetHeight).toString()))}filterTokensWithText(e,t){return e.filter(e=>`${e.symbol} ${e.name} ${e.address}`.toLowerCase().includes(t.toLowerCase()))}};M.styles=R,W([(0,n.wk)()],M.prototype,"interval",void 0),W([(0,n.wk)()],M.prototype,"targetToken",void 0),W([(0,n.wk)()],M.prototype,"sourceToken",void 0),W([(0,n.wk)()],M.prototype,"sourceTokenAmount",void 0),W([(0,n.wk)()],M.prototype,"toToken",void 0),W([(0,n.wk)()],M.prototype,"myTokensWithBalance",void 0),W([(0,n.wk)()],M.prototype,"popularTokens",void 0),W([(0,n.wk)()],M.prototype,"searchValue",void 0),M=W([(0,h.EM)("w3m-swap-select-token-view")],M)}}]);

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.