import PeraRedirectIcon from "../../asset/icon/PeraRedirectIcon.svg"; import {generatePeraWalletAppDeepLink} from "../../util/peraWalletUtils"; import { PERA_WALLET_REDIRECT_MODAL_ID, removeModalWrapperFromDOM } from "../peraWalletConnectModalUtils"; import styles from "./_pera-wallet-redirect-modal.scss"; const peraWalletRedirectModalTemplate = document.createElement("template"); peraWalletRedirectModalTemplate.innerHTML = `

Can't Launch Pera

We couldn't redirect you to Pera Wallet automatically. Please try again.

Don't have Pera Wallet installed yet?
Tap here to install.

Launch Pera Wallet
`; export class PeraWalletRedirectModal extends HTMLElement { constructor() { super(); this.attachShadow({mode: "open"}); if (this.shadowRoot) { const styleSheet = document.createElement("style"); styleSheet.textContent = styles; this.shadowRoot.append( peraWalletRedirectModalTemplate.content.cloneNode(true), styleSheet ); const downloadPeraLink = this.shadowRoot?.getElementById( "pera-wallet-redirect-modal-download-pera-link" ); downloadPeraLink?.addEventListener("click", () => { this.onClose(); }); const launchPeraLink = this.shadowRoot?.getElementById( "pera-wallet-redirect-modal-launch-pera-link" ); launchPeraLink?.addEventListener("click", () => { this.onClose(); window.open(generatePeraWalletAppDeepLink(), "_blank"); }); } } connectedCallback() { const peraWalletDeepLink = window.open(generatePeraWalletAppDeepLink(), "_blank"); if (peraWalletDeepLink && !peraWalletDeepLink.closed) { this.onClose(); } } onClose() { removeModalWrapperFromDOM(PERA_WALLET_REDIRECT_MODAL_ID); } }