coinley-checkout
Version:
A React SDK for Coinley cryptocurrency payment processing with multi-network support
1,419 lines (1,385 loc) • 220 kB
JavaScript
import { i, e as elementStyles, r as resetStyles, a as i$1, x, C as ConnectorController, A as ApiController, b as CoreHelperUtil, E as EventsController, R as RouterController, O as OptionsController, c as ConnectorUtil, d as AssetUtil, f as ConnectionController, S as StorageUtil, g as ConstantsUtil, W as WalletUtil, h as ChainController, j as AssetController, T as ThemeController, k as SnackController, M as ModalController, l as ConstantsUtil$1, m as b, n as E, o as colorStyles } from "./core-be16e657.mjs";
import { n as n$1, c as customElement, o as o$1, r, U as UiHelperUtil, e as e$1, f, a as e$2 } from "./index-e8592264.mjs";
import "./index-2161e56b.mjs";
import "./index-703c58ee.mjs";
import "./index-1c96ce10.mjs";
import "react";
import "./events-856718af.mjs";
import "./index.es-2cef285a.mjs";
import "./index-ad797676.mjs";
const styles$q = i`
:host {
position: relative;
background-color: var(--wui-color-gray-glass-002);
display: flex;
justify-content: center;
align-items: center;
width: var(--local-size);
height: var(--local-size);
border-radius: inherit;
border-radius: var(--local-border-radius);
}
:host > wui-flex {
overflow: hidden;
border-radius: inherit;
border-radius: var(--local-border-radius);
}
:host::after {
content: '';
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
border-radius: inherit;
border: 1px solid var(--wui-color-gray-glass-010);
pointer-events: none;
}
:host([name='Extension'])::after {
border: 1px solid var(--wui-color-accent-glass-010);
}
:host([data-wallet-icon='allWallets']) {
background-color: var(--wui-all-wallets-bg-100);
}
:host([data-wallet-icon='allWallets'])::after {
border: 1px solid var(--wui-color-accent-glass-010);
}
wui-icon[data-parent-size='inherit'] {
width: 75%;
height: 75%;
align-items: center;
}
wui-icon[data-parent-size='sm'] {
width: 18px;
height: 18px;
}
wui-icon[data-parent-size='md'] {
width: 24px;
height: 24px;
}
wui-icon[data-parent-size='lg'] {
width: 42px;
height: 42px;
}
wui-icon[data-parent-size='full'] {
width: 100%;
height: 100%;
}
:host > wui-icon-box {
position: absolute;
overflow: hidden;
right: -1px;
bottom: -2px;
z-index: 1;
border: 2px solid var(--wui-color-bg-150, #1e1f1f);
padding: 1px;
}
`;
var __decorate$K = globalThis && globalThis.__decorate || function(decorators, target, key, desc) {
var c = arguments.length, r2 = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
r2 = Reflect.decorate(decorators, target, key, desc);
else
for (var i2 = decorators.length - 1; i2 >= 0; i2--)
if (d = decorators[i2])
r2 = (c < 3 ? d(r2) : c > 3 ? d(target, key, r2) : d(target, key)) || r2;
return c > 3 && r2 && Object.defineProperty(target, key, r2), r2;
};
let WuiWalletImage = class WuiWalletImage2 extends i$1 {
constructor() {
super(...arguments);
this.size = "md";
this.name = "";
this.installed = false;
this.badgeSize = "xs";
}
render() {
let borderRadius = "xxs";
if (this.size === "lg") {
borderRadius = "m";
} else if (this.size === "md") {
borderRadius = "xs";
} else {
borderRadius = "xxs";
}
this.style.cssText = `
--local-border-radius: var(--wui-border-radius-${borderRadius});
--local-size: var(--wui-wallet-image-size-${this.size});
`;
if (this.walletIcon) {
this.dataset["walletIcon"] = this.walletIcon;
}
return x`
<wui-flex justifyContent="center" alignItems="center"> ${this.templateVisual()} </wui-flex>
`;
}
templateVisual() {
if (this.imageSrc) {
return x`<wui-image src=${this.imageSrc} alt=${this.name}></wui-image>`;
} else if (this.walletIcon) {
return x`<wui-icon
data-parent-size="md"
size="md"
color="inherit"
name=${this.walletIcon}
></wui-icon>`;
}
return x`<wui-icon
data-parent-size=${this.size}
size="inherit"
color="inherit"
name="walletPlaceholder"
></wui-icon>`;
}
};
WuiWalletImage.styles = [elementStyles, resetStyles, styles$q];
__decorate$K([
n$1()
], WuiWalletImage.prototype, "size", void 0);
__decorate$K([
n$1()
], WuiWalletImage.prototype, "name", void 0);
__decorate$K([
n$1()
], WuiWalletImage.prototype, "imageSrc", void 0);
__decorate$K([
n$1()
], WuiWalletImage.prototype, "walletIcon", void 0);
__decorate$K([
n$1({ type: Boolean })
], WuiWalletImage.prototype, "installed", void 0);
__decorate$K([
n$1()
], WuiWalletImage.prototype, "badgeSize", void 0);
WuiWalletImage = __decorate$K([
customElement("wui-wallet-image")
], WuiWalletImage);
const styles$p = i`
:host {
position: relative;
border-radius: var(--wui-border-radius-xxs);
width: 40px;
height: 40px;
overflow: hidden;
background: var(--wui-color-gray-glass-002);
display: flex;
justify-content: center;
align-items: center;
flex-wrap: wrap;
gap: var(--wui-spacing-4xs);
padding: 3.75px !important;
}
:host::after {
content: '';
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
border-radius: inherit;
border: 1px solid var(--wui-color-gray-glass-010);
pointer-events: none;
}
:host > wui-wallet-image {
width: 14px;
height: 14px;
border-radius: var(--wui-border-radius-5xs);
}
:host > wui-flex {
padding: 2px;
position: fixed;
overflow: hidden;
left: 34px;
bottom: 8px;
background: var(--dark-background-150, #1e1f1f);
border-radius: 50%;
z-index: 2;
display: flex;
}
`;
var __decorate$J = globalThis && globalThis.__decorate || function(decorators, target, key, desc) {
var c = arguments.length, r2 = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
r2 = Reflect.decorate(decorators, target, key, desc);
else
for (var i2 = decorators.length - 1; i2 >= 0; i2--)
if (d = decorators[i2])
r2 = (c < 3 ? d(r2) : c > 3 ? d(target, key, r2) : d(target, key)) || r2;
return c > 3 && r2 && Object.defineProperty(target, key, r2), r2;
};
const TOTAL_IMAGES = 4;
let WuiAllWalletsImage = class WuiAllWalletsImage2 extends i$1 {
constructor() {
super(...arguments);
this.walletImages = [];
}
render() {
const isPlaceholders = this.walletImages.length < TOTAL_IMAGES;
return x`${this.walletImages.slice(0, TOTAL_IMAGES).map(({ src, walletName }) => x`
<wui-wallet-image
size="inherit"
imageSrc=${src}
name=${o$1(walletName)}
></wui-wallet-image>
`)}
${isPlaceholders ? [...Array(TOTAL_IMAGES - this.walletImages.length)].map(() => x` <wui-wallet-image size="inherit" name=""></wui-wallet-image>`) : null}
<wui-flex>
<wui-icon-box
size="xxs"
iconSize="xxs"
iconcolor="success-100"
backgroundcolor="success-100"
icon="checkmark"
background="opaque"
></wui-icon-box>
</wui-flex>`;
}
};
WuiAllWalletsImage.styles = [resetStyles, styles$p];
__decorate$J([
n$1({ type: Array })
], WuiAllWalletsImage.prototype, "walletImages", void 0);
WuiAllWalletsImage = __decorate$J([
customElement("wui-all-wallets-image")
], WuiAllWalletsImage);
const styles$o = i`
button {
column-gap: var(--wui-spacing-s);
padding: 7px var(--wui-spacing-l) 7px var(--wui-spacing-xs);
width: 100%;
background-color: var(--wui-color-gray-glass-002);
border-radius: var(--wui-border-radius-xs);
color: var(--wui-color-fg-100);
}
button > wui-text:nth-child(2) {
display: flex;
flex: 1;
}
button:disabled {
background-color: var(--wui-color-gray-glass-015);
color: var(--wui-color-gray-glass-015);
}
button:disabled > wui-tag {
background-color: var(--wui-color-gray-glass-010);
color: var(--wui-color-fg-300);
}
wui-icon {
color: var(--wui-color-fg-200) !important;
}
`;
var __decorate$I = globalThis && globalThis.__decorate || function(decorators, target, key, desc) {
var c = arguments.length, r2 = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
r2 = Reflect.decorate(decorators, target, key, desc);
else
for (var i2 = decorators.length - 1; i2 >= 0; i2--)
if (d = decorators[i2])
r2 = (c < 3 ? d(r2) : c > 3 ? d(target, key, r2) : d(target, key)) || r2;
return c > 3 && r2 && Object.defineProperty(target, key, r2), r2;
};
let WuiListWallet = class WuiListWallet2 extends i$1 {
constructor() {
super(...arguments);
this.walletImages = [];
this.imageSrc = "";
this.name = "";
this.tabIdx = void 0;
this.installed = false;
this.disabled = false;
this.showAllWallets = false;
this.loading = false;
this.loadingSpinnerColor = "accent-100";
}
render() {
return x`
<button ?disabled=${this.disabled} tabindex=${o$1(this.tabIdx)}>
${this.templateAllWallets()} ${this.templateWalletImage()}
<wui-text variant="paragraph-500" color="inherit">${this.name}</wui-text>
${this.templateStatus()}
</button>
`;
}
templateAllWallets() {
if (this.showAllWallets && this.imageSrc) {
return x` <wui-all-wallets-image .imageeSrc=${this.imageSrc}> </wui-all-wallets-image> `;
} else if (this.showAllWallets && this.walletIcon) {
return x` <wui-wallet-image .walletIcon=${this.walletIcon} size="sm"> </wui-wallet-image> `;
}
return null;
}
templateWalletImage() {
if (!this.showAllWallets && this.imageSrc) {
return x`<wui-wallet-image
size="sm"
imageSrc=${this.imageSrc}
name=${this.name}
.installed=${this.installed}
></wui-wallet-image>`;
} else if (!this.showAllWallets && !this.imageSrc) {
return x`<wui-wallet-image size="sm" name=${this.name}></wui-wallet-image>`;
}
return null;
}
templateStatus() {
if (this.loading) {
return x`<wui-loading-spinner
size="lg"
color=${this.loadingSpinnerColor}
></wui-loading-spinner>`;
} else if (this.tagLabel && this.tagVariant) {
return x`<wui-tag variant=${this.tagVariant}>${this.tagLabel}</wui-tag>`;
} else if (this.icon) {
return x`<wui-icon color="inherit" size="sm" name=${this.icon}></wui-icon>`;
}
return null;
}
};
WuiListWallet.styles = [resetStyles, elementStyles, styles$o];
__decorate$I([
n$1({ type: Array })
], WuiListWallet.prototype, "walletImages", void 0);
__decorate$I([
n$1()
], WuiListWallet.prototype, "imageSrc", void 0);
__decorate$I([
n$1()
], WuiListWallet.prototype, "name", void 0);
__decorate$I([
n$1()
], WuiListWallet.prototype, "tagLabel", void 0);
__decorate$I([
n$1()
], WuiListWallet.prototype, "tagVariant", void 0);
__decorate$I([
n$1()
], WuiListWallet.prototype, "icon", void 0);
__decorate$I([
n$1()
], WuiListWallet.prototype, "walletIcon", void 0);
__decorate$I([
n$1()
], WuiListWallet.prototype, "tabIdx", void 0);
__decorate$I([
n$1({ type: Boolean })
], WuiListWallet.prototype, "installed", void 0);
__decorate$I([
n$1({ type: Boolean })
], WuiListWallet.prototype, "disabled", void 0);
__decorate$I([
n$1({ type: Boolean })
], WuiListWallet.prototype, "showAllWallets", void 0);
__decorate$I([
n$1({ type: Boolean })
], WuiListWallet.prototype, "loading", void 0);
__decorate$I([
n$1({ type: String })
], WuiListWallet.prototype, "loadingSpinnerColor", void 0);
WuiListWallet = __decorate$I([
customElement("wui-list-wallet")
], WuiListWallet);
var __decorate$H = globalThis && globalThis.__decorate || function(decorators, target, key, desc) {
var c = arguments.length, r2 = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
r2 = Reflect.decorate(decorators, target, key, desc);
else
for (var i2 = decorators.length - 1; i2 >= 0; i2--)
if (d = decorators[i2])
r2 = (c < 3 ? d(r2) : c > 3 ? d(target, key, r2) : d(target, key)) || r2;
return c > 3 && r2 && Object.defineProperty(target, key, r2), r2;
};
let W3mAllWalletsWidget = class W3mAllWalletsWidget2 extends i$1 {
constructor() {
super();
this.unsubscribe = [];
this.tabIdx = void 0;
this.connectors = ConnectorController.state.connectors;
this.count = ApiController.state.count;
this.filteredCount = ApiController.state.filteredWallets.length;
this.isFetchingRecommendedWallets = ApiController.state.isFetchingRecommendedWallets;
this.unsubscribe.push(ConnectorController.subscribeKey("connectors", (val) => this.connectors = val), ApiController.subscribeKey("count", (val) => this.count = val), ApiController.subscribeKey("filteredWallets", (val) => this.filteredCount = val.length), ApiController.subscribeKey("isFetchingRecommendedWallets", (val) => this.isFetchingRecommendedWallets = val));
}
disconnectedCallback() {
this.unsubscribe.forEach((unsubscribe) => unsubscribe());
}
render() {
const wcConnector = this.connectors.find((c) => c.id === "walletConnect");
const { allWallets } = OptionsController.state;
if (!wcConnector || allWallets === "HIDE") {
return null;
}
if (allWallets === "ONLY_MOBILE" && !CoreHelperUtil.isMobile()) {
return null;
}
const featuredCount = ApiController.state.featured.length;
const rawCount = this.count + featuredCount;
const roundedCount = rawCount < 10 ? rawCount : Math.floor(rawCount / 10) * 10;
const count = this.filteredCount > 0 ? this.filteredCount : roundedCount;
let tagLabel = `${count}`;
if (this.filteredCount > 0) {
tagLabel = `${this.filteredCount}`;
} else if (count < rawCount) {
tagLabel = `${count}+`;
}
return x`
<wui-list-wallet
name="All Wallets"
walletIcon="allWallets"
showAllWallets
@click=${this.onAllWallets.bind(this)}
tagLabel=${tagLabel}
tagVariant="shade"
data-testid="all-wallets"
tabIdx=${o$1(this.tabIdx)}
.loading=${this.isFetchingRecommendedWallets}
loadingSpinnerColor=${this.isFetchingRecommendedWallets ? "fg-300" : "accent-100"}
></wui-list-wallet>
`;
}
onAllWallets() {
EventsController.sendEvent({ type: "track", event: "CLICK_ALL_WALLETS" });
RouterController.push("AllWallets");
}
};
__decorate$H([
n$1()
], W3mAllWalletsWidget.prototype, "tabIdx", void 0);
__decorate$H([
r()
], W3mAllWalletsWidget.prototype, "connectors", void 0);
__decorate$H([
r()
], W3mAllWalletsWidget.prototype, "count", void 0);
__decorate$H([
r()
], W3mAllWalletsWidget.prototype, "filteredCount", void 0);
__decorate$H([
r()
], W3mAllWalletsWidget.prototype, "isFetchingRecommendedWallets", void 0);
W3mAllWalletsWidget = __decorate$H([
customElement("w3m-all-wallets-widget")
], W3mAllWalletsWidget);
var __decorate$G = globalThis && globalThis.__decorate || function(decorators, target, key, desc) {
var c = arguments.length, r2 = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
r2 = Reflect.decorate(decorators, target, key, desc);
else
for (var i2 = decorators.length - 1; i2 >= 0; i2--)
if (d = decorators[i2])
r2 = (c < 3 ? d(r2) : c > 3 ? d(target, key, r2) : d(target, key)) || r2;
return c > 3 && r2 && Object.defineProperty(target, key, r2), r2;
};
let W3mConnectAnnouncedWidget = class W3mConnectAnnouncedWidget2 extends i$1 {
constructor() {
super();
this.unsubscribe = [];
this.tabIdx = void 0;
this.connectors = ConnectorController.state.connectors;
this.unsubscribe.push(ConnectorController.subscribeKey("connectors", (val) => this.connectors = val));
}
disconnectedCallback() {
this.unsubscribe.forEach((unsubscribe) => unsubscribe());
}
render() {
const announcedConnectors = this.connectors.filter((connector) => connector.type === "ANNOUNCED");
if (!announcedConnectors?.length) {
this.style.cssText = `display: none`;
return null;
}
return x`
<wui-flex flexDirection="column" gap="xs">
${announcedConnectors.filter(ConnectorUtil.showConnector).map((connector) => x`
<wui-list-wallet
imageSrc=${o$1(AssetUtil.getConnectorImage(connector))}
name=${connector.name ?? "Unknown"}
@click=${() => this.onConnector(connector)}
tagVariant="success"
tagLabel="installed"
data-testid=${`wallet-selector-${connector.id}`}
.installed=${true}
tabIdx=${o$1(this.tabIdx)}
>
</wui-list-wallet>
`)}
</wui-flex>
`;
}
onConnector(connector) {
if (connector.id === "walletConnect") {
if (CoreHelperUtil.isMobile()) {
RouterController.push("AllWallets");
} else {
RouterController.push("ConnectingWalletConnect");
}
} else {
RouterController.push("ConnectingExternal", { connector });
}
}
};
__decorate$G([
n$1()
], W3mConnectAnnouncedWidget.prototype, "tabIdx", void 0);
__decorate$G([
r()
], W3mConnectAnnouncedWidget.prototype, "connectors", void 0);
W3mConnectAnnouncedWidget = __decorate$G([
customElement("w3m-connect-announced-widget")
], W3mConnectAnnouncedWidget);
var __decorate$F = globalThis && globalThis.__decorate || function(decorators, target, key, desc) {
var c = arguments.length, r2 = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
r2 = Reflect.decorate(decorators, target, key, desc);
else
for (var i2 = decorators.length - 1; i2 >= 0; i2--)
if (d = decorators[i2])
r2 = (c < 3 ? d(r2) : c > 3 ? d(target, key, r2) : d(target, key)) || r2;
return c > 3 && r2 && Object.defineProperty(target, key, r2), r2;
};
let W3mConnectCustomWidget = class W3mConnectCustomWidget2 extends i$1 {
constructor() {
super();
this.unsubscribe = [];
this.tabIdx = void 0;
this.connectors = ConnectorController.state.connectors;
this.loading = false;
this.unsubscribe.push(ConnectorController.subscribeKey("connectors", (val) => this.connectors = val));
if (CoreHelperUtil.isTelegram() && CoreHelperUtil.isIos()) {
this.loading = !ConnectionController.state.wcUri;
this.unsubscribe.push(ConnectionController.subscribeKey("wcUri", (val) => this.loading = !val));
}
}
disconnectedCallback() {
this.unsubscribe.forEach((unsubscribe) => unsubscribe());
}
render() {
const { customWallets } = OptionsController.state;
if (!customWallets?.length) {
this.style.cssText = `display: none`;
return null;
}
const wallets = this.filterOutDuplicateWallets(customWallets);
return x`<wui-flex flexDirection="column" gap="xs">
${wallets.map((wallet) => x`
<wui-list-wallet
imageSrc=${o$1(AssetUtil.getWalletImage(wallet))}
name=${wallet.name ?? "Unknown"}
@click=${() => this.onConnectWallet(wallet)}
data-testid=${`wallet-selector-${wallet.id}`}
tabIdx=${o$1(this.tabIdx)}
?loading=${this.loading}
>
</wui-list-wallet>
`)}
</wui-flex>`;
}
filterOutDuplicateWallets(wallets) {
const recent = StorageUtil.getRecentWallets();
const connectorRDNSs = this.connectors.map((connector) => connector.info?.rdns).filter(Boolean);
const recentRDNSs = recent.map((wallet) => wallet.rdns).filter(Boolean);
const allRDNSs = connectorRDNSs.concat(recentRDNSs);
if (allRDNSs.includes("io.metamask.mobile") && CoreHelperUtil.isMobile()) {
const index = allRDNSs.indexOf("io.metamask.mobile");
allRDNSs[index] = "io.metamask";
}
const filtered = wallets.filter((wallet) => !allRDNSs.includes(String(wallet?.rdns)));
return filtered;
}
onConnectWallet(wallet) {
if (this.loading) {
return;
}
RouterController.push("ConnectingWalletConnect", { wallet });
}
};
__decorate$F([
n$1()
], W3mConnectCustomWidget.prototype, "tabIdx", void 0);
__decorate$F([
r()
], W3mConnectCustomWidget.prototype, "connectors", void 0);
__decorate$F([
r()
], W3mConnectCustomWidget.prototype, "loading", void 0);
W3mConnectCustomWidget = __decorate$F([
customElement("w3m-connect-custom-widget")
], W3mConnectCustomWidget);
var __decorate$E = globalThis && globalThis.__decorate || function(decorators, target, key, desc) {
var c = arguments.length, r2 = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
r2 = Reflect.decorate(decorators, target, key, desc);
else
for (var i2 = decorators.length - 1; i2 >= 0; i2--)
if (d = decorators[i2])
r2 = (c < 3 ? d(r2) : c > 3 ? d(target, key, r2) : d(target, key)) || r2;
return c > 3 && r2 && Object.defineProperty(target, key, r2), r2;
};
let W3mConnectExternalWidget = class W3mConnectExternalWidget2 extends i$1 {
constructor() {
super();
this.unsubscribe = [];
this.tabIdx = void 0;
this.connectors = ConnectorController.state.connectors;
this.unsubscribe.push(ConnectorController.subscribeKey("connectors", (val) => this.connectors = val));
}
disconnectedCallback() {
this.unsubscribe.forEach((unsubscribe) => unsubscribe());
}
render() {
const externalConnectors = this.connectors.filter((connector) => connector.type === "EXTERNAL");
const filteredOutExcludedConnectors = externalConnectors.filter(ConnectorUtil.showConnector);
const filteredOutCoinbaseConnectors = filteredOutExcludedConnectors.filter((connector) => connector.id !== ConstantsUtil.CONNECTOR_ID.COINBASE_SDK);
if (!filteredOutCoinbaseConnectors?.length) {
this.style.cssText = `display: none`;
return null;
}
return x`
<wui-flex flexDirection="column" gap="xs">
${filteredOutCoinbaseConnectors.map((connector) => x`
<wui-list-wallet
imageSrc=${o$1(AssetUtil.getConnectorImage(connector))}
.installed=${true}
name=${connector.name ?? "Unknown"}
data-testid=${`wallet-selector-external-${connector.id}`}
@click=${() => this.onConnector(connector)}
tabIdx=${o$1(this.tabIdx)}
>
</wui-list-wallet>
`)}
</wui-flex>
`;
}
onConnector(connector) {
RouterController.push("ConnectingExternal", { connector });
}
};
__decorate$E([
n$1()
], W3mConnectExternalWidget.prototype, "tabIdx", void 0);
__decorate$E([
r()
], W3mConnectExternalWidget.prototype, "connectors", void 0);
W3mConnectExternalWidget = __decorate$E([
customElement("w3m-connect-external-widget")
], W3mConnectExternalWidget);
var __decorate$D = globalThis && globalThis.__decorate || function(decorators, target, key, desc) {
var c = arguments.length, r2 = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
r2 = Reflect.decorate(decorators, target, key, desc);
else
for (var i2 = decorators.length - 1; i2 >= 0; i2--)
if (d = decorators[i2])
r2 = (c < 3 ? d(r2) : c > 3 ? d(target, key, r2) : d(target, key)) || r2;
return c > 3 && r2 && Object.defineProperty(target, key, r2), r2;
};
let W3mConnectFeaturedWidget = class W3mConnectFeaturedWidget2 extends i$1 {
constructor() {
super(...arguments);
this.tabIdx = void 0;
this.wallets = [];
}
render() {
if (!this.wallets.length) {
this.style.cssText = `display: none`;
return null;
}
return x`
<wui-flex flexDirection="column" gap="xs">
${this.wallets.map((wallet) => x`
<wui-list-wallet
data-testid=${`wallet-selector-featured-${wallet.id}`}
imageSrc=${o$1(AssetUtil.getWalletImage(wallet))}
name=${wallet.name ?? "Unknown"}
@click=${() => this.onConnectWallet(wallet)}
tabIdx=${o$1(this.tabIdx)}
>
</wui-list-wallet>
`)}
</wui-flex>
`;
}
onConnectWallet(wallet) {
ConnectorController.selectWalletConnector(wallet);
}
};
__decorate$D([
n$1()
], W3mConnectFeaturedWidget.prototype, "tabIdx", void 0);
__decorate$D([
n$1()
], W3mConnectFeaturedWidget.prototype, "wallets", void 0);
W3mConnectFeaturedWidget = __decorate$D([
customElement("w3m-connect-featured-widget")
], W3mConnectFeaturedWidget);
var __decorate$C = globalThis && globalThis.__decorate || function(decorators, target, key, desc) {
var c = arguments.length, r2 = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
r2 = Reflect.decorate(decorators, target, key, desc);
else
for (var i2 = decorators.length - 1; i2 >= 0; i2--)
if (d = decorators[i2])
r2 = (c < 3 ? d(r2) : c > 3 ? d(target, key, r2) : d(target, key)) || r2;
return c > 3 && r2 && Object.defineProperty(target, key, r2), r2;
};
let W3mConnectInjectedWidget = class W3mConnectInjectedWidget2 extends i$1 {
constructor() {
super(...arguments);
this.tabIdx = void 0;
this.connectors = [];
}
render() {
const injectedConnectors = this.connectors.filter(ConnectorUtil.showConnector);
if (injectedConnectors.length === 0) {
this.style.cssText = `display: none`;
return null;
}
return x`
<wui-flex flexDirection="column" gap="xs">
${injectedConnectors.map((connector) => x`
<wui-list-wallet
imageSrc=${o$1(AssetUtil.getConnectorImage(connector))}
.installed=${true}
name=${connector.name ?? "Unknown"}
tagVariant="success"
tagLabel="installed"
data-testid=${`wallet-selector-${connector.id}`}
@click=${() => this.onConnector(connector)}
tabIdx=${o$1(this.tabIdx)}
>
</wui-list-wallet>
`)}
</wui-flex>
`;
}
onConnector(connector) {
ConnectorController.setActiveConnector(connector);
RouterController.push("ConnectingExternal", { connector });
}
};
__decorate$C([
n$1()
], W3mConnectInjectedWidget.prototype, "tabIdx", void 0);
__decorate$C([
n$1()
], W3mConnectInjectedWidget.prototype, "connectors", void 0);
W3mConnectInjectedWidget = __decorate$C([
customElement("w3m-connect-injected-widget")
], W3mConnectInjectedWidget);
var __decorate$B = globalThis && globalThis.__decorate || function(decorators, target, key, desc) {
var c = arguments.length, r2 = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
r2 = Reflect.decorate(decorators, target, key, desc);
else
for (var i2 = decorators.length - 1; i2 >= 0; i2--)
if (d = decorators[i2])
r2 = (c < 3 ? d(r2) : c > 3 ? d(target, key, r2) : d(target, key)) || r2;
return c > 3 && r2 && Object.defineProperty(target, key, r2), r2;
};
let W3mConnectMultiChainWidget = class W3mConnectMultiChainWidget2 extends i$1 {
constructor() {
super();
this.unsubscribe = [];
this.tabIdx = void 0;
this.connectors = ConnectorController.state.connectors;
this.unsubscribe.push(ConnectorController.subscribeKey("connectors", (val) => this.connectors = val));
}
disconnectedCallback() {
this.unsubscribe.forEach((unsubscribe) => unsubscribe());
}
render() {
const multiChainConnectors = this.connectors.filter((connector) => connector.type === "MULTI_CHAIN" && connector.name !== "WalletConnect");
if (!multiChainConnectors?.length) {
this.style.cssText = `display: none`;
return null;
}
return x`
<wui-flex flexDirection="column" gap="xs">
${multiChainConnectors.map((connector) => x`
<wui-list-wallet
imageSrc=${o$1(AssetUtil.getConnectorImage(connector))}
.installed=${true}
name=${connector.name ?? "Unknown"}
tagVariant="shade"
tagLabel="multichain"
data-testid=${`wallet-selector-${connector.id}`}
@click=${() => this.onConnector(connector)}
tabIdx=${o$1(this.tabIdx)}
>
</wui-list-wallet>
`)}
</wui-flex>
`;
}
onConnector(connector) {
ConnectorController.setActiveConnector(connector);
RouterController.push("ConnectingMultiChain");
}
};
__decorate$B([
n$1()
], W3mConnectMultiChainWidget.prototype, "tabIdx", void 0);
__decorate$B([
r()
], W3mConnectMultiChainWidget.prototype, "connectors", void 0);
W3mConnectMultiChainWidget = __decorate$B([
customElement("w3m-connect-multi-chain-widget")
], W3mConnectMultiChainWidget);
var __decorate$A = globalThis && globalThis.__decorate || function(decorators, target, key, desc) {
var c = arguments.length, r2 = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
r2 = Reflect.decorate(decorators, target, key, desc);
else
for (var i2 = decorators.length - 1; i2 >= 0; i2--)
if (d = decorators[i2])
r2 = (c < 3 ? d(r2) : c > 3 ? d(target, key, r2) : d(target, key)) || r2;
return c > 3 && r2 && Object.defineProperty(target, key, r2), r2;
};
let W3mConnectRecentWidget = class W3mConnectRecentWidget2 extends i$1 {
constructor() {
super();
this.unsubscribe = [];
this.tabIdx = void 0;
this.connectors = ConnectorController.state.connectors;
this.loading = false;
this.unsubscribe.push(ConnectorController.subscribeKey("connectors", (val) => this.connectors = val));
if (CoreHelperUtil.isTelegram() && CoreHelperUtil.isIos()) {
this.loading = !ConnectionController.state.wcUri;
this.unsubscribe.push(ConnectionController.subscribeKey("wcUri", (val) => this.loading = !val));
}
}
render() {
const recentWallets = StorageUtil.getRecentWallets();
const filteredRecentWallets = recentWallets.filter((wallet) => !WalletUtil.isExcluded(wallet)).filter((wallet) => !this.hasWalletConnector(wallet)).filter((wallet) => this.isWalletCompatibleWithCurrentChain(wallet));
if (!filteredRecentWallets.length) {
this.style.cssText = `display: none`;
return null;
}
return x`
<wui-flex flexDirection="column" gap="xs">
${filteredRecentWallets.map((wallet) => x`
<wui-list-wallet
imageSrc=${o$1(AssetUtil.getWalletImage(wallet))}
name=${wallet.name ?? "Unknown"}
@click=${() => this.onConnectWallet(wallet)}
tagLabel="recent"
tagVariant="shade"
tabIdx=${o$1(this.tabIdx)}
?loading=${this.loading}
>
</wui-list-wallet>
`)}
</wui-flex>
`;
}
onConnectWallet(wallet) {
if (this.loading) {
return;
}
ConnectorController.selectWalletConnector(wallet);
}
hasWalletConnector(wallet) {
return this.connectors.some((connector) => connector.id === wallet.id || connector.name === wallet.name);
}
isWalletCompatibleWithCurrentChain(wallet) {
const currentNamespace = ChainController.state.activeChain;
if (currentNamespace && wallet.chains) {
return wallet.chains.some((c) => {
const chainNamespace = c.split(":")[0];
return currentNamespace === chainNamespace;
});
}
return true;
}
};
__decorate$A([
n$1()
], W3mConnectRecentWidget.prototype, "tabIdx", void 0);
__decorate$A([
r()
], W3mConnectRecentWidget.prototype, "connectors", void 0);
__decorate$A([
r()
], W3mConnectRecentWidget.prototype, "loading", void 0);
W3mConnectRecentWidget = __decorate$A([
customElement("w3m-connect-recent-widget")
], W3mConnectRecentWidget);
var __decorate$z = globalThis && globalThis.__decorate || function(decorators, target, key, desc) {
var c = arguments.length, r2 = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
r2 = Reflect.decorate(decorators, target, key, desc);
else
for (var i2 = decorators.length - 1; i2 >= 0; i2--)
if (d = decorators[i2])
r2 = (c < 3 ? d(r2) : c > 3 ? d(target, key, r2) : d(target, key)) || r2;
return c > 3 && r2 && Object.defineProperty(target, key, r2), r2;
};
let W3mConnectRecommendedWidget = class W3mConnectRecommendedWidget2 extends i$1 {
constructor() {
super();
this.unsubscribe = [];
this.tabIdx = void 0;
this.wallets = [];
this.loading = false;
if (CoreHelperUtil.isTelegram() && CoreHelperUtil.isIos()) {
this.loading = !ConnectionController.state.wcUri;
this.unsubscribe.push(ConnectionController.subscribeKey("wcUri", (val) => this.loading = !val));
}
}
render() {
const { connectors } = ConnectorController.state;
const { customWallets, featuredWalletIds } = OptionsController.state;
const recentWallets = StorageUtil.getRecentWallets();
const wcConnector = connectors.find((c) => c.id === "walletConnect");
const injectedConnectors = connectors.filter((c) => c.type === "INJECTED" || c.type === "ANNOUNCED" || c.type === "MULTI_CHAIN");
const injectedWallets = injectedConnectors.filter((i2) => i2.name !== "Browser Wallet");
if (!wcConnector) {
return null;
}
if (featuredWalletIds || customWallets || !this.wallets.length) {
this.style.cssText = `display: none`;
return null;
}
const overrideLength = injectedWallets.length + recentWallets.length;
const maxRecommended = Math.max(0, 2 - overrideLength);
const wallets = WalletUtil.filterOutDuplicateWallets(this.wallets).slice(0, maxRecommended);
if (!wallets.length) {
this.style.cssText = `display: none`;
return null;
}
return x`
<wui-flex flexDirection="column" gap="xs">
${wallets.map((wallet) => x`
<wui-list-wallet
imageSrc=${o$1(AssetUtil.getWalletImage(wallet))}
name=${wallet?.name ?? "Unknown"}
@click=${() => this.onConnectWallet(wallet)}
tabIdx=${o$1(this.tabIdx)}
?loading=${this.loading}
>
</wui-list-wallet>
`)}
</wui-flex>
`;
}
onConnectWallet(wallet) {
if (this.loading) {
return;
}
const connector = ConnectorController.getConnector(wallet.id, wallet.rdns);
if (connector) {
RouterController.push("ConnectingExternal", { connector });
} else {
RouterController.push("ConnectingWalletConnect", { wallet });
}
}
};
__decorate$z([
n$1()
], W3mConnectRecommendedWidget.prototype, "tabIdx", void 0);
__decorate$z([
n$1()
], W3mConnectRecommendedWidget.prototype, "wallets", void 0);
__decorate$z([
r()
], W3mConnectRecommendedWidget.prototype, "loading", void 0);
W3mConnectRecommendedWidget = __decorate$z([
customElement("w3m-connect-recommended-widget")
], W3mConnectRecommendedWidget);
var __decorate$y = globalThis && globalThis.__decorate || function(decorators, target, key, desc) {
var c = arguments.length, r2 = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
r2 = Reflect.decorate(decorators, target, key, desc);
else
for (var i2 = decorators.length - 1; i2 >= 0; i2--)
if (d = decorators[i2])
r2 = (c < 3 ? d(r2) : c > 3 ? d(target, key, r2) : d(target, key)) || r2;
return c > 3 && r2 && Object.defineProperty(target, key, r2), r2;
};
let W3mConnectWalletConnectWidget = class W3mConnectWalletConnectWidget2 extends i$1 {
constructor() {
super();
this.unsubscribe = [];
this.tabIdx = void 0;
this.connectors = ConnectorController.state.connectors;
this.connectorImages = AssetController.state.connectorImages;
this.unsubscribe.push(ConnectorController.subscribeKey("connectors", (val) => this.connectors = val), AssetController.subscribeKey("connectorImages", (val) => this.connectorImages = val));
}
disconnectedCallback() {
this.unsubscribe.forEach((unsubscribe) => unsubscribe());
}
render() {
if (CoreHelperUtil.isMobile()) {
this.style.cssText = `display: none`;
return null;
}
const connector = this.connectors.find((c) => c.id === "walletConnect");
if (!connector) {
this.style.cssText = `display: none`;
return null;
}
const connectorImage = connector.imageUrl || this.connectorImages[connector?.imageId ?? ""];
return x`
<wui-list-wallet
imageSrc=${o$1(connectorImage)}
name=${connector.name ?? "Unknown"}
@click=${() => this.onConnector(connector)}
tagLabel="qr code"
tagVariant="main"
tabIdx=${o$1(this.tabIdx)}
data-testid="wallet-selector-walletconnect"
>
</wui-list-wallet>
`;
}
onConnector(connector) {
ConnectorController.setActiveConnector(connector);
RouterController.push("ConnectingWalletConnect");
}
};
__decorate$y([
n$1()
], W3mConnectWalletConnectWidget.prototype, "tabIdx", void 0);
__decorate$y([
r()
], W3mConnectWalletConnectWidget.prototype, "connectors", void 0);
__decorate$y([
r()
], W3mConnectWalletConnectWidget.prototype, "connectorImages", void 0);
W3mConnectWalletConnectWidget = __decorate$y([
customElement("w3m-connect-walletconnect-widget")
], W3mConnectWalletConnectWidget);
const styles$n = i`
:host {
margin-top: var(--wui-spacing-3xs);
}
wui-separator {
margin: var(--wui-spacing-m) calc(var(--wui-spacing-m) * -1) var(--wui-spacing-xs)
calc(var(--wui-spacing-m) * -1);
width: calc(100% + var(--wui-spacing-s) * 2);
}
`;
var __decorate$x = globalThis && globalThis.__decorate || function(decorators, target, key, desc) {
var c = arguments.length, r2 = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
r2 = Reflect.decorate(decorators, target, key, desc);
else
for (var i2 = decorators.length - 1; i2 >= 0; i2--)
if (d = decorators[i2])
r2 = (c < 3 ? d(r2) : c > 3 ? d(target, key, r2) : d(target, key)) || r2;
return c > 3 && r2 && Object.defineProperty(target, key, r2), r2;
};
let W3mConnectorList = class W3mConnectorList2 extends i$1 {
constructor() {
super();
this.unsubscribe = [];
this.tabIdx = void 0;
this.connectors = ConnectorController.state.connectors;
this.recommended = ApiController.state.recommended;
this.featured = ApiController.state.featured;
this.unsubscribe.push(ConnectorController.subscribeKey("connectors", (val) => this.connectors = val), ApiController.subscribeKey("recommended", (val) => this.recommended = val), ApiController.subscribeKey("featured", (val) => this.featured = val));
}
disconnectedCallback() {
this.unsubscribe.forEach((unsubscribe) => unsubscribe());
}
render() {
return x`
<wui-flex flexDirection="column" gap="xs"> ${this.connectorListTemplate()} </wui-flex>
`;
}
connectorListTemplate() {
const { custom, recent, announced, injected, multiChain, recommended, featured, external } = ConnectorUtil.getConnectorsByType(this.connectors, this.recommended, this.featured);
const connectorTypeOrder = ConnectorUtil.getConnectorTypeOrder({
custom,
recent,
announced,
injected,
multiChain,
recommended,
featured,
external
});
return connectorTypeOrder.map((type) => {
switch (type) {
case "injected":
return x`
${multiChain.length ? x`<w3m-connect-multi-chain-widget
tabIdx=${o$1(this.tabIdx)}
></w3m-connect-multi-chain-widget>` : null}
${announced.length ? x`<w3m-connect-announced-widget
tabIdx=${o$1(this.tabIdx)}
></w3m-connect-announced-widget>` : null}
${injected.length ? x`<w3m-connect-injected-widget
.connectors=${injected}
tabIdx=${o$1(this.tabIdx)}
></w3m-connect-injected-widget>` : null}
`;
case "walletConnect":
return x`<w3m-connect-walletconnect-widget
tabIdx=${o$1(this.tabIdx)}
></w3m-connect-walletconnect-widget>`;
case "recent":
return x`<w3m-connect-recent-widget
tabIdx=${o$1(this.tabIdx)}
></w3m-connect-recent-widget>`;
case "featured":
return x`<w3m-connect-featured-widget
.wallets=${featured}
tabIdx=${o$1(this.tabIdx)}
></w3m-connect-featured-widget>`;
case "custom":
return x`<w3m-connect-custom-widget
tabIdx=${o$1(this.tabIdx)}
></w3m-connect-custom-widget>`;
case "external":
return x`<w3m-connect-external-widget
tabIdx=${o$1(this.tabIdx)}
></w3m-connect-external-widget>`;
case "recommended":
return x`<w3m-connect-recommended-widget
.wallets=${recommended}
tabIdx=${o$1(this.tabIdx)}
></w3m-connect-recommended-widget>`;
default:
console.warn(`Unknown connector type: ${type}`);
return null;
}
});
}
};
W3mConnectorList.styles = styles$n;
__decorate$x([
n$1()
], W3mConnectorList.prototype, "tabIdx", void 0);
__decorate$x([
r()
], W3mConnectorList.prototype, "connectors", void 0);
__decorate$x([
r()
], W3mConnectorList.prototype, "recommended", void 0);
__decorate$x([
r()
], W3mConnectorList.prototype, "featured", void 0);
W3mConnectorList = __decorate$x([
customElement("w3m-connector-list")
], W3mConnectorList);
const styles$m = i`
:host {
display: inline-flex;
background-color: var(--wui-color-gray-glass-002);
border-radius: var(--wui-border-radius-3xl);
padding: var(--wui-spacing-3xs);
position: relative;
height: 36px;
min-height: 36px;
overflow: hidden;
}
:host::before {
content: '';
position: absolute;
pointer-events: none;
top: 4px;
left: 4px;
display: block;
width: var(--local-tab-width);
height: 28px;
border-radius: var(--wui-border-radius-3xl);
background-color: var(--wui-color-gray-glass-002);
box-shadow: inset 0 0 0 1px var(--wui-color-gray-glass-002);
transform: translateX(calc(var(--local-tab) * var(--local-tab-width)));
transition: transform var(--wui-ease-out-power-1) var(--wui-duration-md);
will-change: background-color, opacity;
}
:host([data-type='flex'])::before {
left: 3px;
transform: translateX(calc((var(--local-tab) * 34px) + (var(--local-tab) * 4px)));
}
:host([data-type='flex']) {
display: flex;
padding: 0px 0px 0px 12px;
gap: 4px;
}
:host([data-type='flex']) > button > wui-text {
position: absolute;
left: 18px;
opacity: 0;
}
button[data-active='true'] > wui-icon,
button[data-active='true'] > wui-text {
color: var(--wui-color-fg-100);
}
button[data-active='false'] > wui-icon,
button[data-active='false'] > wui-text {
color: var(--wui-color-fg-200);
}
button[data-active='true']:disabled,
button[data-active='false']:disabled {
background-color: transparent;
opacity: 0.5;
cursor: not-allowed;
}
button[data-active='true']:disabled > wui-text {
color: var(--wui-color-fg-200);
}
button[data-active='false']:disabled > wui-text {
color: var(--wui-color-fg-300);
}
button > wui-icon,
button > wui-text {
pointer-events: none;
transition: color var(--wui-e ase-out-power-1) var(--wui-duration-md);
will-change: color;
}
button {
width: var(--local-tab-width);
transition: background-color var(--wui-ease-out-power-1) var(--wui-duration-md);
will-change: background-color;
}
:host([data-type='flex']) > button {
width: 34px;
position: relative;
display: flex;
justify-content: flex-start;
}
button:hover:enabled,
button:active:enabled {
background-color: transparent !important;
}
button:hover:enabled > wui-icon,
button:active:enabled > wui-icon {
transition: all var(--wui-ease-out-power-1) var(--wui-duration-lg);
color: var(--wui-color-fg-125);
}
button:hover:enabled > wui-text,
button:active:enabled > wui-text {
transition: all var(--wui-ease-out-power-1) var(--wui-duration-lg);
color: var(--wui-color-fg-125);
}
button {
border-radius: var(--wui-border-radius-3xl);
}
`;
var __decorate$w = globalThis && globalThis.__decorate || function(decorators, target, key, desc) {
var c = arguments.length, r2 = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
r2 = Reflect.decorate(decorators, target, key, desc);
else
for (var i2 = decorators.length - 1; i2 >= 0; i2--)
if (d = decorators[i2])
r2 = (c < 3 ? d(r2) : c > 3 ? d(target, key, r2) : d(target, key)) || r2;
return c > 3 && r2 && Object.defineProperty(target, key, r2), r2;
};
let WuiTabs = class WuiTabs2 extends i$1 {
constructor() {
super(...arguments);
this.tabs = [];
this.onTabChange = () => null;
this.buttons = [];
this.disabled = false;
this.localTabWidth = "100px";
this.activeTab = 0;
this.isDense = false;
}
render() {
this.isDense = this.tabs.length > 3;
this.style.cssText = `
--local-tab: ${this.activeTab};
--local-tab-width: ${this.localTabWidth};
`;
this.dataset["type"] = this.isDense ? "flex" : "block";
return this.tabs.map((tab, index) => {
const isActive = index === this.activeTab;
return x`
<button
?disabled=${this.disabled}
@click=${() => this.onTabClick(index)}
data-active=${isActive}
data-testid="tab-${tab.label?.toLowerCase()}"
>
${this.iconTemplate(tab)}
<wui-text variant="small-600" color="inherit"> ${tab.label} </wui-text>
</button>
`;
});
}
firstUpdated() {
if (this.shadowRoot && this.isDense) {
this.buttons = [...this.shadowRoot.querySelectorAll("button")];
setTimeout(() => {
this.animateTabs(0, true);
}, 0);
}
}
iconTemplate(tab) {
if (tab.icon) {
return x`<wui-icon size="xs" color="inherit" name=${tab.icon}></wui-icon>`;
}
return null;
}
onTabClick(index) {
if (this.buttons) {
this.animateTabs(index, false);
}
this.activeTab = index;
this.onTabChange(index);
}
animateTabs(index, initialAnimation) {
const passiveBtn = this.buttons[this.activeTab];
const activeBtn = this.buttons[index];
const passiveBtnText = passiveBtn?.querySelector("wui-text");
const activeBtnText = activeBtn?.querySelector("wui-text");
const activeBtnBounds = activeBtn?.getBoundingClientRect();
const activeBtnTextBounds = activeBtnText?.getBoundingClientRect();
if (passiveBtn && passiveBtnText && !initialAnimation && index !== this.activeTab) {
passiveBtnText.animate([{ opacity: 0 }], {
duration: 50,
easing: "ease",
fill: "forwards"
});
passiveBtn.animate([{ width: `34px` }], {
duration: 500,
easing: "ease",
fill: "forwards"
});
}
if (activeBtn && activeBtnBounds && activeBtnTextBounds && activeBtnText) {
if (index !== this.activeTab || initialAnimation) {
this.localTabWidth = `${Math.round(activeBtnBounds.width + activeBtnTextBounds.width) + 6}px`;
activeBtn.animate([{ width: `${activeBtnBounds.width + activeBtnTextBounds.width}px` }], {
duration: initialAnimation ? 0 : 500,
fill: "forwards",
easing: "ease"
});
activeBtnText.animate([{ opacity: 1 }], {
duration: initialAnimation ? 0 : 125,
delay: initialAnimation ? 0 : 200,
fill: "forwards",
easing: "ease"
});
}
}
}
};
WuiTabs.styles = [resetStyles, elementStyles, styles$m];
__decorate$w([
n$1({ type: Array })
], WuiTabs.prototype, "tabs", void 0);
__decorate$w([
n$1()
], WuiTabs.prototype, "onTabChange", void 0);
__decorate$w([
n$1({ type: Array })
], WuiTabs.prototype, "buttons", void 0);
__decorate$w([
n$1({ type: Boolean })
], WuiTabs.prototype, "disabled", void 0);
__decorate$w([
n$1()
], WuiTabs.prototype, "localTabWidth", void 0);
__decorate$w([
r()
], WuiTabs.prototype, "activeTab", void 0);
__decorate$w([
r()
], WuiTabs.prototype, "isDense", void 0);
WuiTabs = __decorate$w([
customElement("wui-tabs")
], WuiTabs);
var __decorate$v = globalThis && globalThis.__decorate || function(deco