import { h, p as proxyCustomElement, H, c as createEvent, F as Fragment } from './p-3b962989.js';
import { D as DataTestIdsEnum } from './p-6e09b0ac.js';
import { d as defineCustomElement$1 } from './p-e9dd5f80.js';

function trimAddress(s) {
    const firstFour = s.slice(0, 6);
    const lastFour = s.slice(-6);
    return `${firstFour}...${lastFour}`;
}
const renderAccounts = ({ shownAccounts = [], onSelectAccount, selectedIndex }) => {
    return (h("div", { class: "account-list", "data-testid": DataTestIdsEnum.addressTableContainer },
        h("div", { class: "account-header" },
            h("div", { class: "account-header-item" }, "Address"),
            h("div", { class: "account-header-item" }, "Balance"),
            h("div", { class: "account-header-item" }, "#")),
        shownAccounts.map(account => (h("div", { class: "account-row", onClick: () => onSelectAccount(account.index) },
            h("div", { class: "address-row-item-data " },
                h("input", { type: "radio", name: "account", checked: account.index === selectedIndex, value: account.index }),
                h("span", { class: "address" }, trimAddress(account.address))),
            h("div", { class: "address-row-item-data" }, account.balance),
            h("div", { class: "address-row-item-data" }, account.index))))));
};

const ledgerAccountScreenCss = "*,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-scroll-snap-strictness:proximity;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;border:0 solid #e5e7eb;box-sizing:border-box}::backdrop{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-scroll-snap-strictness:proximity;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;}/*! tailwindcss v3.4.17 | MIT License | https://tailwindcss.com*/:after,:before{--tw-content:\"\"}:host,html{-webkit-text-size-adjust:100%;font-feature-settings:normal;-webkit-tap-highlight-color:transparent;font-family:ui-sans-serif,system-ui,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;font-variation-settings:normal;line-height:1.5;-moz-tab-size:4;tab-size:4}body{line-height:inherit;margin:0}hr{border-top-width:1px;color:inherit;height:0}abbr:where([title]){text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-feature-settings:normal;font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-size:1em;font-variation-settings:normal}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{border-collapse:collapse;border-color:inherit;text-indent:0}button,input,optgroup,select,textarea{font-feature-settings:inherit;color:inherit;font-family:inherit;font-size:100%;font-variation-settings:inherit;font-weight:inherit;letter-spacing:inherit;line-height:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dd,dl,fieldset,figure,h1,h2,h3,h4,h5,h6,hr,p,pre{margin:0}fieldset,legend{padding:0}menu,ol,ul{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::placeholder,textarea::placeholder{color:#9ca3af;opacity:1}[role=button],button{cursor:pointer}:disabled{cursor:default}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{height:auto;max-width:100%}[hidden]:where(:not([hidden=until-found])){display:none}.relative{position:relative}.block{display:block}.flex{display:flex}.transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.border{border-width:1px}.account-header{align-items:center;background-color:#ced4da;border-radius:8px;display:flex;font-size:14px;line-height:1;padding:16px 20px 16px 16px;text-align:left}.account-header-item{flex:1}.account-header-item:first-child{max-width:55%;width:55%}.account-header-item:last-child{flex-basis:32px;max-width:32px;text-align:center;width:32px}.account-list{max-height:300px;min-height:300px;overflow:auto;position:relative;width:100%}.account-row{align-items:center;border-radius:8px;cursor:pointer;display:flex;padding:16px}.account-row:hover{background-color:#f5f5f5}.address-row-item-data{align-items:center;display:flex;flex:1;font-size:14px;line-height:1;padding-right:16px;text-align:left}.address-row-item-data:last-child{flex-basis:32px;justify-content:center;max-width:32px;padding-right:0;text-align:center;width:32px}.navigation{display:flex;gap:10rem;justify-content:center;margin-top:20px}.navigation-button{background:transparent;border:none;cursor:pointer}.navigation-button:hover{color:#1a56db}.navigation-button:disabled{color:#737373;pointer-events:none}.access-button{background-color:#1a56db;border:none;border-radius:8px;color:#fff;cursor:pointer;display:block;margin:20px auto;padding:12px;width:200px}.access-button:disabled{background-color:#a1a1a1;box-shadow:none;color:#e0e0e0;cursor:not-allowed;opacity:.6;transform:none}.shadow{--tw-shadow:0 1px 3px 0 rgba(0,0,0,.1),0 1px 2px -1px rgba(0,0,0,.1);--tw-shadow-colored:0 1px 3px 0 var(--tw-shadow-color),0 1px 2px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}";
const LedgerAccountScreenStyle0 = ledgerAccountScreenCss;

const LedgerAccountScreen = /*@__PURE__*/ proxyCustomElement(class LedgerAccountScreen extends H {
    constructor() {
        super();
        this.__registerHost();
        this.__attachShadow();
        this.selectAccount = createEvent(this, "selectAccount", 7);
        this.nextPage = createEvent(this, "nextPage", 7);
        this.prevPage = createEvent(this, "prevPage", 7);
        this.accessWallet = createEvent(this, "accessWallet", 7);
    }
    render() {
        const isSelectedIndexOnPage = this.accountScreenData.accounts.some(({ index }) => index === this.selectedIndex);
        const accountsList = this.accountScreenData.isLoading || this.accountScreenData.accounts.length === 0 ? (h("generic-spinner", { "data-testid": DataTestIdsEnum.ledgerLoading })) : (renderAccounts({
            shownAccounts: this.accountScreenData.accounts,
            onSelectAccount: (index) => this.selectAccount.emit(index),
            selectedIndex: this.selectedIndex,
        }));
        return (h(Fragment, { key: '838d37d86d04247b19101ff5dc387a6531c90265' }, accountsList, !this.accountScreenData.isLoading && this.accountScreenData.accounts.length !== 0 && (h(Fragment, { key: 'aeb62e0519bbcc46944ce97bcace57504db3f73b' }, h("div", { key: 'c4bd512b2c8b08591774abc0af92a85e16697c85', class: "navigation" }, h("button", { key: '0c891e5f8af57d75a693f4cf9a12d2114aa493cb', onClick: () => this.prevPage.emit(), disabled: this.accountScreenData.startIndex <= 0, "data-testid": DataTestIdsEnum.prevBtn, class: "navigation-button" }, '< ', " Prev"), h("button", { key: '081d4f65b0c978dc2be6700631d41ae4eadfc1ac', onClick: () => this.nextPage.emit(), "data-testid": DataTestIdsEnum.nextBtn, class: "navigation-button" }, "Next", ' >')), h("button", { key: 'ef36f5928ee6c5a4e90661edffaf41718f35326e', "data-testid": DataTestIdsEnum.confirmBtn, class: "access-button", onClick: () => this.accessWallet.emit(), disabled: !isSelectedIndexOnPage }, "Access Wallet")))));
    }
    static get style() { return LedgerAccountScreenStyle0; }
}, [1, "ledger-account-screen", {
        "accountScreenData": [16],
        "selectedIndex": [2, "selected-index"]
    }]);
function defineCustomElement() {
    if (typeof customElements === "undefined") {
        return;
    }
    const components = ["ledger-account-screen", "generic-spinner"];
    components.forEach(tagName => { switch (tagName) {
        case "ledger-account-screen":
            if (!customElements.get(tagName)) {
                customElements.define(tagName, LedgerAccountScreen);
            }
            break;
        case "generic-spinner":
            if (!customElements.get(tagName)) {
                defineCustomElement$1();
            }
            break;
    } });
}

export { LedgerAccountScreen as L, defineCustomElement as d };

//# sourceMappingURL=p-f27a8a5d.js.map