/*!
 * Crafted with ❤ by Salla
 */
import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
import { c as closeModals } from './functions.js';

const sallaLoyaltyProgramCss = "";

const SallaRewardAction = /*@__PURE__*/ proxyCustomElement(class SallaRewardAction extends HTMLElement {
    constructor() {
        super();
        this.__registerHost();
        this.actionClick = createEvent(this, "actionClick", 7);
        this.isShopNow = (prize) => {
            if (!(salla.config.get('store.features') || []).includes('loyalty-system-v2')) {
                return false;
            }
            return prize.key?.toLowerCase() === 'free_product';
        };
        this.handleClick = (e) => {
            if (salla.config.isGuest()) {
                closeModals(() => salla.event.dispatch('login::open'));
                return;
            }
            this.actionClick.emit(e);
        };
    }
    render() {
        return (h("div", { key: '0d02cecaae79cf166555514890fbf6192e1cd438', class: "s-loyalty-program-rewards-modal-action" }, this.isShopNow(this.prize) ? (h("a", { href: this.prize.prize_url || salla.url.get(''), class: {
                's-loyalty-program-rewards-action-base': true,
                's-loyalty-program-rewards-action-on': true,
            } }, salla.lang.get('pages.loyalty_program.shop_now'))) : (h("button", { onClick: this.handleClick, class: {
                's-loyalty-program-rewards-action-base': true,
                's-loyalty-program-rewards-action-on': true,
            } }, salla.lang.get('pages.loyalty_program.redeem_reward')))));
    }
    static get style() { return sallaLoyaltyProgramCss; }
}, [0, "salla-reward-action", {
        "prize": [16]
    }]);
function defineCustomElement() {
    if (typeof customElements === "undefined") {
        return;
    }
    const components = ["salla-reward-action"];
    components.forEach(tagName => { switch (tagName) {
        case "salla-reward-action":
            if (!customElements.get(tagName)) {
                customElements.define(tagName, SallaRewardAction);
            }
            break;
    } });
}
defineCustomElement();

export { SallaRewardAction as S, defineCustomElement as d };
