import { h } from "@stencil/core";
import JustifiAnalytics from "../../../api/Analytics";
import { checkPkgVersion } from "../../../utils/check-pkg-version";
import { waitForConfig } from "../../config-provider/config-state";
import { StyledHost } from "../../../ui-components";
export class JustifiCardForm {
    async componentWillLoad() {
        await waitForConfig();
        checkPkgVersion();
        this.analytics = new JustifiAnalytics(this);
    }
    disconnectedCallback() {
        var _a;
        (_a = this.analytics) === null || _a === void 0 ? void 0 : _a.cleanup();
    }
    async validate() {
        return this.cardFormElement.validate();
    }
    async tokenize({ clientId, paymentMethodMetadata, account, }) {
        return this.cardFormElement.tokenize({ clientId, paymentMethodMetadata, account });
    }
    render() {
        return (h(StyledHost, { key: 'e8591312a00d22c68812fda0b56a125ffd763e01' }, h("card-form", { key: 'e987ea9f3bcd2bf0aa8b2c6749bff3b902f20519', ref: (el) => (this.cardFormElement = el) })));
    }
    static get is() { return "justifi-card-form"; }
    static get encapsulation() { return "shadow"; }
    static get methods() {
        return {
            "validate": {
                "complexType": {
                    "signature": "() => Promise<any>",
                    "parameters": [],
                    "references": {
                        "Promise": {
                            "location": "global",
                            "id": "global::Promise"
                        }
                    },
                    "return": "Promise<any>"
                },
                "docs": {
                    "text": "",
                    "tags": []
                }
            },
            "tokenize": {
                "complexType": {
                    "signature": "({ clientId, paymentMethodMetadata, account, }: { clientId: string; paymentMethodMetadata: any; account?: string; }) => Promise<any>",
                    "parameters": [{
                            "name": "__0",
                            "type": "{ clientId: string; paymentMethodMetadata: any; account?: string; }",
                            "docs": ""
                        }],
                    "references": {
                        "Promise": {
                            "location": "global",
                            "id": "global::Promise"
                        }
                    },
                    "return": "Promise<any>"
                },
                "docs": {
                    "text": "",
                    "tags": []
                }
            }
        };
    }
}
