var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
import { Component, OnInit, ViewChild, ElementRef, Input, Renderer2, Inject } from '@angular/core';
import { Meta, Title } from '@angular/platform-browser';
import { ComponentHelper } from '../../classes/component-helper';
import { Constants } from '../../core.consts';
import { ParametersService } from '../../services/parameters.service';
var ShareBlockEcComponent = /** @class */ (function (_super) {
    __extends(ShareBlockEcComponent, _super);
    function ShareBlockEcComponent(consts, paramsService, renderer, meta, title) {
        var _this = _super.call(this) || this;
        _this.consts = consts;
        _this.paramsService = paramsService;
        _this.renderer = renderer;
        _this.meta = meta;
        _this.title = title;
        _this.url = '';
        _this.mediaimg = '';
        _this.description = '';
        _this.params = {};
        _this.toShareFacebook = function () {
            //return `https://www.facebook.com/share.php?u=${encodeURIComponent(this.url)}`
            return "https://www.facebook.com/share.php?u=" + _this.url;
        };
        _this.toShareTwitter = function () {
            //return `https://twitter.com/share?text=${encodeURIComponent(this.description)};url=${encodeURIComponent(this.url)}`
            return "https://twitter.com/share?text=" + _this.description + "&url=" + _this.url;
        };
        _this.toSharePinterest = function () {
            //return `https://pinterest.com/pin/create/button/?url=${encodeURIComponent(this.url)}&media=${encodeURIComponent(this.mediaimg)}&description=${encodeURIComponent(this.description)}`
            return "https://pinterest.com/pin/create/button/?url=" + _this.url + "&media=" + (_this.consts.mediaUrl() + _this.mediaimg) + "&description=" + _this.description;
        };
        _this.toShareWhatsapp = function (wsp) {
            return "https://wa.me/" + wsp.value + "?text=Me%20interesa%20este%20producto.%20" + _this.url;
        };
        _this.toShareEmail = function (mail) {
            return "mailto:" + mail.value + "?subject=Consulta%20sobre%20el%20producto:%20" + _this.description + "&body=Art\u00EDculo:%20" + _this.url;
        };
        _this.createMetadata = function () {
            //     <meta name="description" content="Cojín JOY, en algodón rústico súper soft, tonos frescos y naturales, y con detalles de borlas para darle un toque divertido.">
            // <meta property="og:site_name" content="MYC HOME LINENS">
            // <meta property="og:url" content="https://myc-homelinens.com/products/cojin-algodon-joy-azul">
            // <meta property="og:title" content="COJÍN JOY - AZUL">
            // <meta property="og:type" content="product">
            // <meta property="og:description" content="Cojín JOY, en algodón rústico súper soft, tonos frescos y naturales, y con detalles de borlas para darle un toque divertido.">
            // <meta property="og:price:amount" content="20,20">
            // <meta property="og:price:currency" content="EUR">
            // <meta property="og:image" content="http://cdn.shopify.com/s/files/1/0054/8179/1603/products/JOYAZUL45FG_f3304197-1c5a-47e2-b993-8bfcde1f9978_1200x630.png?v=1614246269">
            // <meta property="og:image" content="http://cdn.shopify.com/s/files/1/0054/8179/1603/products/JOYAZULTEXTURA_1200x630.png?v=1614246269">
            // <meta property="og:image" content="http://cdn.shopify.com/s/files/1/0054/8179/1603/products/JOYJUNTOSCUADRADA_69e9dcc0-d4d1-42e1-94f8-30f4ea263325_1200x630.png?v=1614246269">
            // <meta property="og:image:secure_url" content="https://cdn.shopify.com/s/files/1/0054/8179/1603/products/JOYAZUL45FG_f3304197-1c5a-47e2-b993-8bfcde1f9978_1200x630.png?v=1614246269">
            // <meta property="og:image:secure_url" content="https://cdn.shopify.com/s/files/1/0054/8179/1603/products/JOYAZULTEXTURA_1200x630.png?v=1614246269">
            // <meta property="og:image:secure_url" content="https://cdn.shopify.com/s/files/1/0054/8179/1603/products/JOYJUNTOSCUADRADA_69e9dcc0-d4d1-42e1-94f8-30f4ea263325_1200x630.png?v=1614246269">
            // <meta name="twitter:site" content="@">
            // <meta name="twitter:card" content="summary_large_image">
            // <meta name="twitter:title" content="COJÍN JOY - AZUL">
            // <meta name="twitter:description" content="Cojín JOY, en algodón rústico súper soft, tonos frescos y naturales, y con detalles de borlas para darle un toque divertido.">
        };
        _this.ecOnConstruct();
        return _this;
    }
    ShareBlockEcComponent.prototype.ngOnInit = function () {
        var _this = this;
        this.url = window.location.href;
        this.mediaimg = this.product.picturesdefault && this.product.picturesdefault[0];
        this.description = this.product.name;
        if (this.description) {
            this.meta.addTags([
                {
                    name: "description",
                    content: this.description
                },
                {
                    property: "og:site_name",
                    content: this.title.getTitle()
                },
                {
                    property: "og:url",
                    content: this.url
                },
                {
                    property: "og:title",
                    content: this.description
                },
                {
                    property: "og:type",
                    content: 'product'
                },
                {
                    property: "og:price:amount",
                    content: this.product.price
                },
                {
                    property: "og:price:currency",
                    content: this.consts.currency.code
                },
                {
                    property: "og:image",
                    content: this.consts.mediaUrl() + this.mediaimg
                },
                {
                    property: "og:image:secure_url",
                    content: this.consts.mediaUrl() + this.mediaimg
                },
                {
                    property: "witter:site",
                    content: '@'
                },
                {
                    property: "twitter:card",
                    content: 'summary_large_image'
                },
                {
                    property: "twitter:title",
                    content: this.description
                },
                {
                    property: "twitter:description",
                    content: this.description
                }
            ], true);
        }
        this.paramsService.parameters.subscribe(function (res) {
            var _a;
            _this.params = res != null ? (_a = res) === null || _a === void 0 ? void 0 : _a.filter(function (elem) { return elem.code.includes('share'); }) : [];
        });
        this.ecOnInit();
    };
    ShareBlockEcComponent.ctorParameters = function () { return [
        { type: Constants },
        { type: ParametersService },
        { type: Renderer2 },
        { type: Meta },
        { type: Title }
    ]; };
    __decorate([
        Input()
    ], ShareBlockEcComponent.prototype, "product", void 0);
    ShareBlockEcComponent = __decorate([
        Component({
            selector: 'app-share-block-ec',
            template: "<div class=\"w-100 d-flex justify-content-around\">\n    <ng-container *ngIf=\"params && params.length > 0; else default\">\n        <a *ngIf=\"hasParams(params, 'facebook')\" target=\"_blank\" [href]=\"toShareFacebook()\"\n            class=\"social-sharing__link\" title=\"Compartir en Facebook\">\n            <svg aria-hidden=\"true\" focusable=\"false\" role=\"presentation\" class=\"icon icon-facebook\" viewBox=\"0 0 32 32\">\n                <path fill=\"#444\"\n                    d=\"M18.56 31.36V17.28h4.48l.64-5.12h-5.12v-3.2c0-1.28.64-2.56 2.56-2.56h2.56V1.28H19.2c-3.84 0-7.04 2.56-7.04 7.04v3.84H7.68v5.12h4.48v14.08h6.4z\">\n                </path>\n            </svg>\n            <span class=\"social-sharing__title\" aria-hidden=\"true\">Compartir</span>\n        </a>\n        <a *ngIf=\"hasParams(params, 'twitter')\" target=\"_blank\" \n            [href]=\"toShareTwitter()\"\n            class=\"social-sharing__link\" title=\"Tuitear en Twitter\">\n            <svg aria-hidden=\"true\" focusable=\"false\" role=\"presentation\" class=\"icon icon-twitter\" viewBox=\"0 0 32 32\">\n                <path fill=\"#444\"\n                    d=\"M31.281 6.733q-1.304 1.924-3.13 3.26 0 .13.033.408t.033.408q0 2.543-.75 5.086t-2.282 4.858-3.635 4.108-5.053 2.869-6.341 1.076q-5.282 0-9.65-2.836.913.065 1.5.065 4.401 0 7.857-2.673-2.054-.033-3.668-1.255t-2.266-3.146q.554.13 1.206.13.88 0 1.663-.261-2.184-.456-3.619-2.184t-1.435-3.977v-.065q1.239.652 2.836.717-1.271-.848-2.021-2.233t-.75-2.983q0-1.63.815-3.195 2.38 2.967 5.754 4.678t7.319 1.907q-.228-.815-.228-1.434 0-2.608 1.858-4.45t4.532-1.842q1.304 0 2.51.522t2.054 1.467q2.152-.424 4.01-1.532-.685 2.217-2.771 3.488 1.989-.261 3.619-.978z\">\n                </path>\n            </svg>\n            <span class=\"social-sharing__title\" aria-hidden=\"true\">Tuitear</span>\n        </a>\n        <a *ngIf=\"hasParams(params, 'pinterest')\" target=\"_blank\"\n            [href]=\"toSharePinterest()\"\n            class=\"social-sharing__link\" title=\"Pinear en Pinterest\">\n            <svg aria-hidden=\"true\" focusable=\"false\" role=\"presentation\" class=\"icon icon-pinterest\" viewBox=\"0 0 32 32\">\n                <path fill=\"#444\"\n                    d=\"M27.52 9.6c-.64-5.76-6.4-8.32-12.8-7.68-4.48.64-9.6 4.48-9.6 10.24 0 3.2.64 5.76 3.84 6.4 1.28-2.56-.64-3.2-.64-4.48-1.28-7.04 8.32-12.16 13.44-7.04 3.2 3.84 1.28 14.08-4.48 13.44-5.12-1.28 2.56-9.6-1.92-11.52-3.2-1.28-5.12 4.48-3.84 7.04-1.28 4.48-3.2 8.96-1.92 15.36 2.56-1.92 3.84-5.76 4.48-9.6 1.28.64 1.92 1.92 3.84 1.92 6.4-.64 10.24-7.68 9.6-14.08z\">\n                </path>\n            </svg>\n            <span class=\"social-sharing__title\" aria-hidden=\"true\">Hacer pin</span>\n        </a>\n        <a *ngIf=\"hasParams(params, 'whatsapp') as wsp\" target=\"_blank\" [href]=\"toShareWhatsapp(wsp)\" class=\"social-sharing__link\" title=\"Whatsapp\">\n            <svg xmlns=\"http://www.w3.org/2000/svg\" aria-hidden=\"true\" focusable=\"false\" role=\"presentation\" fill=\"currentColor\" class=\"bi bi-whatsapp\"\n                viewBox=\"0 0 16 16\">\n                <path\n                    d=\"M13.601 2.326A7.854 7.854 0 0 0 7.994 0C3.627 0 .068 3.558.064 7.926c0 1.399.366 2.76 1.057 3.965L0 16l4.204-1.102a7.933 7.933 0 0 0 3.79.965h.004c4.368 0 7.926-3.558 7.93-7.93A7.898 7.898 0 0 0 13.6 2.326zM7.994 14.521a6.573 6.573 0 0 1-3.356-.92l-.24-.144-2.494.654.666-2.433-.156-.251a6.56 6.56 0 0 1-1.007-3.505c0-3.626 2.957-6.584 6.591-6.584a6.56 6.56 0 0 1 4.66 1.931 6.557 6.557 0 0 1 1.928 4.66c-.004 3.639-2.961 6.592-6.592 6.592zm3.615-4.934c-.197-.099-1.17-.578-1.353-.646-.182-.065-.315-.099-.445.099-.133.197-.513.646-.627.775-.114.133-.232.148-.43.05-.197-.1-.836-.308-1.592-.985-.59-.525-.985-1.175-1.103-1.372-.114-.198-.011-.304.088-.403.087-.088.197-.232.296-.346.1-.114.133-.198.198-.33.065-.134.034-.248-.015-.347-.05-.099-.445-1.076-.612-1.47-.16-.389-.323-.335-.445-.34-.114-.007-.247-.007-.38-.007a.729.729 0 0 0-.529.247c-.182.198-.691.677-.691 1.654 0 .977.71 1.916.81 2.049.098.133 1.394 2.132 3.383 2.992.47.205.84.326 1.129.418.475.152.904.129 1.246.08.38-.058 1.171-.48 1.338-.943.164-.464.164-.86.114-.943-.049-.084-.182-.133-.38-.232z\" />\n            </svg>\n            <span class=\"social-sharing__title\" aria-hidden=\"true\">Whatsapp</span>\n        </a>\n        <a *ngIf=\"hasParams(params, 'email') as email\" target=\"_blank\" [href]=\"toShareEmail(email)\" class=\"social-sharing__link\"\n            title=\"Email\">\n            <svg xmlns=\"http://www.w3.org/2000/svg\" aria-hidden=\"true\" focusable=\"false\" role=\"presentation\" fill=\"currentColor\" class=\"bi bi-envelope-fill\"\n                viewBox=\"0 0 16 16\">\n                <path\n                    d=\"M.05 3.555A2 2 0 0 1 2 2h12a2 2 0 0 1 1.95 1.555L8 8.414.05 3.555ZM0 4.697v7.104l5.803-3.558L0 4.697ZM6.761 8.83l-6.57 4.027A2 2 0 0 0 2 14h12a2 2 0 0 0 1.808-1.144l-6.57-4.027L8 9.586l-1.239-.757Zm3.436-.586L16 11.801V4.697l-5.803 3.546Z\" />\n            </svg>\n            <span class=\"social-sharing__title\" aria-hidden=\"true\">Email</span>\n        </a>\n    </ng-container>\n</div>\n\n<!-- VISTA DEFAULT CON LINKS QUE NO REQUIEREN PARAMETROS-->\n<ng-template #default>\n    <a target=\"_blank\" [href]=\"toShareFacebook()\" class=\"social-sharing__link\" title=\"Compartir en Facebook\">\n        <svg aria-hidden=\"true\" focusable=\"false\" role=\"presentation\" class=\"icon icon-facebook\" viewBox=\"0 0 32 32\">\n            <path fill=\"#444\"\n                d=\"M18.56 31.36V17.28h4.48l.64-5.12h-5.12v-3.2c0-1.28.64-2.56 2.56-2.56h2.56V1.28H19.2c-3.84 0-7.04 2.56-7.04 7.04v3.84H7.68v5.12h4.48v14.08h6.4z\">\n            </path>\n        </svg>\n        <span class=\"social-sharing__title\" aria-hidden=\"true\">Compartir</span>\n    </a>\n    <a target=\"_blank\" [href]=\"toShareTwitter()\" class=\"social-sharing__link\" title=\"Tuitear en Twitter\">\n        <svg aria-hidden=\"true\" focusable=\"false\" role=\"presentation\" class=\"icon icon-twitter\" viewBox=\"0 0 32 32\">\n            <path fill=\"#444\"\n                d=\"M31.281 6.733q-1.304 1.924-3.13 3.26 0 .13.033.408t.033.408q0 2.543-.75 5.086t-2.282 4.858-3.635 4.108-5.053 2.869-6.341 1.076q-5.282 0-9.65-2.836.913.065 1.5.065 4.401 0 7.857-2.673-2.054-.033-3.668-1.255t-2.266-3.146q.554.13 1.206.13.88 0 1.663-.261-2.184-.456-3.619-2.184t-1.435-3.977v-.065q1.239.652 2.836.717-1.271-.848-2.021-2.233t-.75-2.983q0-1.63.815-3.195 2.38 2.967 5.754 4.678t7.319 1.907q-.228-.815-.228-1.434 0-2.608 1.858-4.45t4.532-1.842q1.304 0 2.51.522t2.054 1.467q2.152-.424 4.01-1.532-.685 2.217-2.771 3.488 1.989-.261 3.619-.978z\">\n            </path>\n        </svg>\n        <span class=\"social-sharing__title\" aria-hidden=\"true\">Tuitear</span>\n    </a>\n    <a target=\"_blank\" [href]=\"toSharePinterest()\" class=\"social-sharing__link\" title=\"Pinear en Pinterest\">\n        <svg aria-hidden=\"true\" focusable=\"false\" role=\"presentation\" class=\"icon icon-pinterest\" viewBox=\"0 0 32 32\">\n            <path fill=\"#444\"\n                d=\"M27.52 9.6c-.64-5.76-6.4-8.32-12.8-7.68-4.48.64-9.6 4.48-9.6 10.24 0 3.2.64 5.76 3.84 6.4 1.28-2.56-.64-3.2-.64-4.48-1.28-7.04 8.32-12.16 13.44-7.04 3.2 3.84 1.28 14.08-4.48 13.44-5.12-1.28 2.56-9.6-1.92-11.52-3.2-1.28-5.12 4.48-3.84 7.04-1.28 4.48-3.2 8.96-1.92 15.36 2.56-1.92 3.84-5.76 4.48-9.6 1.28.64 1.92 1.92 3.84 1.92 6.4-.64 10.24-7.68 9.6-14.08z\">\n            </path>\n        </svg>\n        <span class=\"social-sharing__title\" aria-hidden=\"true\">Hacer pin</span>\n    </a>\n</ng-template>\n<!-- FIN -->",
            styles: ["a{color:#000}"]
        })
    ], ShareBlockEcComponent);
    return ShareBlockEcComponent;
}(ComponentHelper));
export { ShareBlockEcComponent };
//# sourceMappingURL=data:application/json;base64, 