import { Component, EventEmitter, Input, Output } from '@angular/core';
import { CHECK_COLOR_IS_WHITE, GREY_COLOR, INSPIRE_BLUE_COLOR } from '../inspire-library.const';
import * as i0 from "@angular/core";
import * as i1 from "@angular/common";
import * as i2 from "../ellipsis-menu/ellipsis-menu.component";
function CommunitySponsorsComponent_a_3_Template(rf, ctx) { if (rf & 1) {
    const _r7 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "a", 16);
    i0.ɵɵlistener("click", function CommunitySponsorsComponent_a_3_Template_a_click_0_listener() { i0.ɵɵrestoreView(_r7); const ctx_r6 = i0.ɵɵnextContext(); return ctx_r6.onToggleFollow(); });
    i0.ɵɵelement(1, "i", 17);
    i0.ɵɵtext(2);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngClass", ctx_r0.isFollowing ? "icn-tick" : "icn-plus");
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate1(" ", ctx_r0.isFollowing ? "Following" : "Follow", " ");
} }
function CommunitySponsorsComponent_a_6_Template(rf, ctx) { if (rf & 1) {
    const _r9 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "a", 18);
    i0.ɵɵlistener("click", function CommunitySponsorsComponent_a_6_Template_a_click_0_listener() { i0.ɵɵrestoreView(_r9); const ctx_r8 = i0.ɵɵnextContext(); return ctx_r8.onJoin(); });
    i0.ɵɵelement(1, "i", 19);
    i0.ɵɵtext(2, " Join Community ");
    i0.ɵɵelementEnd();
} }
function CommunitySponsorsComponent_a_7_Template(rf, ctx) { if (rf & 1) {
    const _r11 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "a", 20);
    i0.ɵɵlistener("click", function CommunitySponsorsComponent_a_7_Template_a_click_0_listener() { i0.ɵɵrestoreView(_r11); const ctx_r10 = i0.ɵɵnextContext(); return ctx_r10.onLeave(); });
    i0.ɵɵelement(1, "i", 21);
    i0.ɵɵtext(2, " Leave Community ");
    i0.ɵɵelementEnd();
} }
function CommunitySponsorsComponent_a_8_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "a", 22);
    i0.ɵɵelement(1, "i", 23);
    i0.ɵɵtext(2);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r3 = i0.ɵɵnextContext();
    i0.ɵɵproperty("href", ctx_r3.community == null ? null : ctx_r3.community.assets == null ? null : ctx_r3.community.assets.iconnect_link == null ? null : ctx_r3.community.assets.iconnect_link.link_target, i0.ɵɵsanitizeUrl);
    i0.ɵɵadvance(2);
    i0.ɵɵtextInterpolate1(" ", ctx_r3.community == null ? null : ctx_r3.community.assets == null ? null : ctx_r3.community.assets.iconnect_link == null ? null : ctx_r3.community.assets.iconnect_link.link_text, "");
} }
function CommunitySponsorsComponent_a_9_Template(rf, ctx) { if (rf & 1) {
    const _r13 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "a", 24);
    i0.ɵɵlistener("click", function CommunitySponsorsComponent_a_9_Template_a_click_0_listener() { i0.ɵɵrestoreView(_r13); const ctx_r12 = i0.ɵɵnextContext(); return ctx_r12.onToggleDisclaimer(); });
    i0.ɵɵelement(1, "i", 25);
    i0.ɵɵtext(2, " Disclaimer ");
    i0.ɵɵelementEnd();
} }
function CommunitySponsorsComponent_a_13_Template(rf, ctx) { if (rf & 1) {
    const _r15 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "a", 26);
    i0.ɵɵlistener("click", function CommunitySponsorsComponent_a_13_Template_a_click_0_listener() { i0.ɵɵrestoreView(_r15); const ctx_r14 = i0.ɵɵnextContext(); return ctx_r14.onToggleMobileResourcesView(); });
    i0.ɵɵelement(1, "i", 27);
    i0.ɵɵtext(2, " Resources ");
    i0.ɵɵelementEnd();
} }
const _c0 = function (a0) { return { "background-color": a0 }; };
const _c1 = function (a0, a1) { return { "background-image": a0, "background-color": a1 }; };
export class CommunitySponsorsComponent {
    constructor() {
        this.isFollowing = false;
        this.hasJoinedCommunity = false;
        this.isLoggedIn = false;
        this.isMobile = false;
        this.showDisclaimerOption = false;
        this.communitySectionLinks = [];
        this.join = new EventEmitter();
        this.leave = new EventEmitter();
        this.toggleFollow = new EventEmitter();
        this.toggleDisclaimer = new EventEmitter();
        this.toggleMobileResourcesView = new EventEmitter();
        this.topBarColor = '';
        this.backgroundColor = '';
    }
    ngOnInit() {
        this.init();
    }
    init() {
        var _a;
        if ((_a = this.community) === null || _a === void 0 ? void 0 : _a.assets) {
            this.topBarColor = this.getTopBarColor(this.community.assets);
            this.backgroundColor = this.getHeaderBackgroundColor(this.community.assets);
        }
    }
    ngOnChanges() {
        this.init();
    }
    onLeave() {
        this.leave.emit();
    }
    onJoin() {
        this.join.emit();
    }
    onToggleFollow() {
        this.toggleFollow.emit();
    }
    onToggleDisclaimer() {
        this.toggleDisclaimer.emit();
    }
    onToggleMobileResourcesView() {
        this.toggleMobileResourcesView.emit();
    }
    getTopBarColor(communityAsset) {
        let topBarColor = INSPIRE_BLUE_COLOR;
        if (communityAsset === null || communityAsset === void 0 ? void 0 : communityAsset.accent_color) {
            topBarColor = communityAsset === null || communityAsset === void 0 ? void 0 : communityAsset.accent_color;
        }
        else if (communityAsset === null || communityAsset === void 0 ? void 0 : communityAsset.header_color) {
            topBarColor = communityAsset === null || communityAsset === void 0 ? void 0 : communityAsset.header_color;
        }
        return topBarColor;
    }
    getHeaderBackgroundColor(communityAsset) {
        let backgroundColor = INSPIRE_BLUE_COLOR;
        if ((communityAsset === null || communityAsset === void 0 ? void 0 : communityAsset.header_color) && !this.checkIsWhite(communityAsset === null || communityAsset === void 0 ? void 0 : communityAsset.header_color)) {
            backgroundColor = communityAsset === null || communityAsset === void 0 ? void 0 : communityAsset.header_color;
        }
        else if (communityAsset === null || communityAsset === void 0 ? void 0 : communityAsset.accent_color) {
            backgroundColor = this.checkIsWhite(communityAsset === null || communityAsset === void 0 ? void 0 : communityAsset.accent_color)
                ? GREY_COLOR
                : communityAsset === null || communityAsset === void 0 ? void 0 : communityAsset.accent_color;
        }
        return backgroundColor;
    }
    checkIsWhite(color) {
        return CHECK_COLOR_IS_WHITE(color);
    }
}
CommunitySponsorsComponent.ɵfac = function CommunitySponsorsComponent_Factory(t) { return new (t || CommunitySponsorsComponent)(); };
CommunitySponsorsComponent.ɵcmp = i0.ɵɵdefineComponent({ type: CommunitySponsorsComponent, selectors: [["ins-community-sponsors"]], inputs: { isFollowing: "isFollowing", hasJoinedCommunity: "hasJoinedCommunity", community: "community", isLoggedIn: "isLoggedIn", isMobile: "isMobile", showDisclaimerOption: "showDisclaimerOption", communitySectionLinks: "communitySectionLinks" }, outputs: { join: "join", leave: "leave", toggleFollow: "toggleFollow", toggleDisclaimer: "toggleDisclaimer", toggleMobileResourcesView: "toggleMobileResourcesView" }, features: [i0.ɵɵNgOnChangesFeature], decls: 17, vars: 15, consts: [[1, "community-border", 3, "ngStyle"], [1, "community-bnr", 3, "ngStyle"], [1, "community-bnr-actions"], ["class", "cbc-follow", "id", "follow-toggle-link", 3, "click", 4, "ngIf"], [1, "cbc-spacer"], [1, "cbc-ellipsis"], ["class", "em-link", "id", "join-community", 3, "click", 4, "ngIf"], ["class", "em-link", "id", "leave-community", 3, "click", 4, "ngIf"], ["class", "em-link", "id", "clinical-trials", "target", "blank", 3, "href", 4, "ngIf"], ["class", "em-link", "id", "disclaimer-option", 3, "click", 4, "ngIf"], ["id", "help-me", "href", "/help", 1, "em-link"], [1, "icn-help", "em-icon"], ["class", "em-link", "id", "community-resources-link", 3, "click", 4, "ngIf"], [1, "cb-logo"], ["id", "community-logo-link", "target", "_blank"], ["alt", "image", 3, "src"], ["id", "follow-toggle-link", 1, "cbc-follow", 3, "click"], [3, "ngClass"], ["id", "join-community", 1, "em-link", 3, "click"], [1, "icn-join-community", "em-icon"], ["id", "leave-community", 1, "em-link", 3, "click"], [1, "icn-leave-community", "em-icon"], ["id", "clinical-trials", "target", "blank", 1, "em-link", 3, "href"], [1, "icn-stethoscope", "em-icon"], ["id", "disclaimer-option", 1, "em-link", 3, "click"], [1, "icn-disclaimer", "em-icon"], ["id", "community-resources-link", 1, "em-link", 3, "click"], [1, "icn-resources", "em-icon"]], template: function CommunitySponsorsComponent_Template(rf, ctx) { if (rf & 1) {
        i0.ɵɵelement(0, "div", 0);
        i0.ɵɵelementStart(1, "div", 1);
        i0.ɵɵelementStart(2, "div", 2);
        i0.ɵɵtemplate(3, CommunitySponsorsComponent_a_3_Template, 3, 2, "a", 3);
        i0.ɵɵelement(4, "div", 4);
        i0.ɵɵelementStart(5, "ins-ellipsis-menu", 5);
        i0.ɵɵtemplate(6, CommunitySponsorsComponent_a_6_Template, 3, 0, "a", 6);
        i0.ɵɵtemplate(7, CommunitySponsorsComponent_a_7_Template, 3, 0, "a", 7);
        i0.ɵɵtemplate(8, CommunitySponsorsComponent_a_8_Template, 3, 2, "a", 8);
        i0.ɵɵtemplate(9, CommunitySponsorsComponent_a_9_Template, 3, 0, "a", 9);
        i0.ɵɵelementStart(10, "a", 10);
        i0.ɵɵelement(11, "i", 11);
        i0.ɵɵtext(12, " Help Me");
        i0.ɵɵelementEnd();
        i0.ɵɵtemplate(13, CommunitySponsorsComponent_a_13_Template, 3, 0, "a", 12);
        i0.ɵɵelementEnd();
        i0.ɵɵelementEnd();
        i0.ɵɵelementStart(14, "figure", 13);
        i0.ɵɵelementStart(15, "a", 14);
        i0.ɵɵelement(16, "img", 15);
        i0.ɵɵelementEnd();
        i0.ɵɵelementEnd();
        i0.ɵɵelementEnd();
    } if (rf & 2) {
        i0.ɵɵproperty("ngStyle", i0.ɵɵpureFunction1(10, _c0, ctx.topBarColor));
        i0.ɵɵadvance(1);
        i0.ɵɵproperty("ngStyle", i0.ɵɵpureFunction2(12, _c1, "url(" + (ctx.community == null ? null : ctx.community.assets == null ? null : ctx.community.assets.background_image) + ")", ctx.backgroundColor));
        i0.ɵɵadvance(2);
        i0.ɵɵproperty("ngIf", ctx.isLoggedIn);
        i0.ɵɵadvance(3);
        i0.ɵɵproperty("ngIf", !ctx.hasJoinedCommunity);
        i0.ɵɵadvance(1);
        i0.ɵɵproperty("ngIf", ctx.hasJoinedCommunity);
        i0.ɵɵadvance(1);
        i0.ɵɵproperty("ngIf", ctx.community == null ? null : ctx.community.assets == null ? null : ctx.community.assets.iconnect_link);
        i0.ɵɵadvance(1);
        i0.ɵɵproperty("ngIf", !ctx.isLoggedIn && ctx.showDisclaimerOption);
        i0.ɵɵadvance(4);
        i0.ɵɵproperty("ngIf", ctx.isMobile && (ctx.communitySectionLinks == null ? null : ctx.communitySectionLinks.length));
        i0.ɵɵadvance(2);
        i0.ɵɵattribute("href", (ctx.community == null ? null : ctx.community.assets == null ? null : ctx.community.assets.partners[0] == null ? null : ctx.community.assets.partners[0].url) || null, i0.ɵɵsanitizeUrl);
        i0.ɵɵadvance(1);
        i0.ɵɵproperty("src", ctx.community == null ? null : ctx.community.assets == null ? null : ctx.community.assets.logo_image, i0.ɵɵsanitizeUrl);
    } }, directives: [i1.NgStyle, i1.NgIf, i2.EllipsisMenuComponent, i1.NgClass], styles: ["a[_ngcontent-%COMP%]{text-decoration:none}*[_ngcontent-%COMP%]{font-family:Lato,sans-serif;outline:0}@font-face{font-family:ins-icons;src:url(/assets/fonts/icons/ins-icons.ttf?nf14g1) format(\"truetype\"),url(/assets/fonts/icons/ins-icons.woff?nf14g1) format(\"woff\"),url(/assets/fonts/icons/ins-icons.svg?nf14g1#ins-icons) format(\"svg\");font-weight:400;font-style:normal;font-display:block}.ins-icon[_ngcontent-%COMP%], [class*=\" icn-\"][_ngcontent-%COMP%], [class^=icn-][_ngcontent-%COMP%]{font-family:ins-icons!important;speak:never;font-style:normal;font-weight:400;font-variant:normal;text-transform:none;line-height:1;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.icn-minus-o[_ngcontent-%COMP%]:before{content:\"\\e93a\"}.icn-disclaimer[_ngcontent-%COMP%]:before{content:\"\\e934\"}.icn-leave-community[_ngcontent-%COMP%]:before{content:\"\\e935\"}.icn-stethoscope[_ngcontent-%COMP%]:before{content:\"\\e936\"}.icn-join-community[_ngcontent-%COMP%]:before{content:\"\\e937\"}.icn-resources[_ngcontent-%COMP%]:before{content:\"\\e938\"}.icn-help[_ngcontent-%COMP%]:before{content:\"\\e939\"}.icn-checked[_ngcontent-%COMP%]:before{content:\"\\e933\"}.icn-plus[_ngcontent-%COMP%]:before{content:\"\\e932\"}.icn-expand[_ngcontent-%COMP%]:before{content:\"\\e931\"}.icn-Invite[_ngcontent-%COMP%]:before{content:\"\\e930\"}.icn-report[_ngcontent-%COMP%]:before{content:\"\\e92f\"}.icn-unfollow[_ngcontent-%COMP%]:before{content:\"\\e92e\"}.icn-block[_ngcontent-%COMP%]:before{content:\"\\e92d\"}.icn-trash[_ngcontent-%COMP%]:before{content:\"\\e92b\"}.icn-follow[_ngcontent-%COMP%]:before{content:\"\\e92c\"}.icn-lock[_ngcontent-%COMP%]:before{content:\"\\e92a\"}.icn-bolt-left[_ngcontent-%COMP%]:before{content:\"\\e925\"}.icn-bolt-right[_ngcontent-%COMP%]:before{content:\"\\e926\"}.icn-bolt-down[_ngcontent-%COMP%]:before{content:\"\\e927\"}.icn-bolt-up[_ngcontent-%COMP%]:before{content:\"\\e928\"}.icn-img-o[_ngcontent-%COMP%]:before{content:\"\\e929\"}.icn-tick[_ngcontent-%COMP%]:before{content:\"\\e924\"}.icn-tick-o[_ngcontent-%COMP%]:before{content:\"\\e923\"}.icn-cross-o[_ngcontent-%COMP%]:before{content:\"\\e922\"}.icn-plus-o[_ngcontent-%COMP%]:before{content:\"\\e921\"}.icn-hide[_ngcontent-%COMP%]:before{content:\"\\e920\"}.icn-menu[_ngcontent-%COMP%]:before{content:\"\\e900\"}.icn-more[_ngcontent-%COMP%]:before{content:\"\\e901\"}.icn-msgs[_ngcontent-%COMP%]:before{content:\"\\e902\"}.icn-pin[_ngcontent-%COMP%]:before{content:\"\\e903\"}.icn-reply[_ngcontent-%COMP%]:before{content:\"\\e904\"}.icn-search[_ngcontent-%COMP%]:before{content:\"\\e905\"}.icn-settings[_ngcontent-%COMP%]:before{content:\"\\e906\"}.icn-treatment[_ngcontent-%COMP%]:before{content:\"\\e907\"}.icn-aid[_ngcontent-%COMP%]:before{content:\"\\e908\"}.icn-apple[_ngcontent-%COMP%]:before{content:\"\\e909\"}.icn-arrow-down[_ngcontent-%COMP%]:before{content:\"\\e90a\"}.icn-arrow-up[_ngcontent-%COMP%]:before{content:\"\\e91d\"}.icn-arrow-left[_ngcontent-%COMP%]:before{content:\"\\e91e\"}.icn-arrow-right[_ngcontent-%COMP%]:before{content:\"\\e91f\"}.icn-bell[_ngcontent-%COMP%]:before{content:\"\\e90b\"}.icn-bookmark-o[_ngcontent-%COMP%]:before{content:\"\\e90c\"}.icn-calendar[_ngcontent-%COMP%]:before{content:\"\\e90d\"}.icn-check[_ngcontent-%COMP%]:before{content:\"\\e90e\"}.icn-community[_ngcontent-%COMP%]:before{content:\"\\e90f\"}.icn-d-arrow-up[_ngcontent-%COMP%]:before{content:\"\\e910\"}.icn-discussion[_ngcontent-%COMP%]:before{content:\"\\e911\"}.icn-edit[_ngcontent-%COMP%]:before{content:\"\\e912\"}.icn-facebook[_ngcontent-%COMP%]:before{content:\"\\e913\"}.icn-filters[_ngcontent-%COMP%]:before{content:\"\\e914\"}.icn-friends[_ngcontent-%COMP%]:before{content:\"\\e915\"}.icn-google[_ngcontent-%COMP%]:before{content:\"\\e916\"}.icn-heart[_ngcontent-%COMP%]:before{content:\"\\e917\"}.icn-home[_ngcontent-%COMP%]:before{content:\"\\e918\"}.icn-img[_ngcontent-%COMP%]:before{content:\"\\e919\"}.icn-inspire[_ngcontent-%COMP%]:before{content:\"\\e91a\"}.icn-journal[_ngcontent-%COMP%]:before{content:\"\\e91b\"}.icn-like[_ngcontent-%COMP%]:before{content:\"\\e91c\"}[_nghost-%COMP%]{display:block;position:relative;z-index:1}.community-bnr[_ngcontent-%COMP%]{height:8.4375rem;background:0 0/cover no-repeat #ccc;position:relative;margin:0 -30px;display:flex;align-items:center;justify-content:center;border-bottom:1px solid #e2e5e4}@media (max-width:767px){.community-bnr[_ngcontent-%COMP%]{height:77px;margin:0 -16px}}.community-bnr[_ngcontent-%COMP%]:before{z-index:1;content:\"\";position:absolute;top:0;left:0;width:100%;height:70%;background:linear-gradient(to bottom,rgba(0,0,0,.5) 0,rgba(0,0,0,0) 100%)}.community-border[_ngcontent-%COMP%]{height:7px;background:#061a73;width:100%;position:fixed;left:0;right:0;z-index:2}.cb-logo[_ngcontent-%COMP%]{width:90px;height:90px;border-radius:100%;overflow:hidden;background:#ccc;flex:0 0 auto;margin:7px 0 0;position:relative;z-index:1}.cb-logo[_ngcontent-%COMP%]   img[_ngcontent-%COMP%]{width:100%;height:100%;-o-object-fit:cover;object-fit:cover}@media (max-width:767px){.cb-logo[_ngcontent-%COMP%]{width:54px;height:54px}}.community-bnr-actions[_ngcontent-%COMP%]{display:flex;justify-content:space-between;align-items:center;position:absolute;z-index:2;padding:1rem 1rem 0;width:100%;top:0;left:0}.cbc-spacer[_ngcontent-%COMP%]{flex:1 1 auto}.cbc-follow[_ngcontent-%COMP%]{font-size:.75rem;color:#fff;display:flex;align-items:center;text-shadow:0 2px 1px rgba(0,0,0,.3);cursor:pointer}.cbc-follow[_ngcontent-%COMP%]   i[_ngcontent-%COMP%]{margin-right:.3125rem;font-size:.5rem}.cbc-ellipsis[_ngcontent-%COMP%]{display:block}[_nghost-%COMP%]     .em-btn{color:#fff!important;text-shadow:0 2px 1px rgba(0,0,0,.3)}"] });
/*@__PURE__*/ (function () { i0.ɵsetClassMetadata(CommunitySponsorsComponent, [{
        type: Component,
        args: [{
                selector: 'ins-community-sponsors',
                templateUrl: './community-sponsors.component.html',
                styleUrls: ['./community-sponsors.component.scss']
            }]
    }], function () { return []; }, { isFollowing: [{
            type: Input
        }], hasJoinedCommunity: [{
            type: Input
        }], community: [{
            type: Input
        }], isLoggedIn: [{
            type: Input
        }], isMobile: [{
            type: Input
        }], showDisclaimerOption: [{
            type: Input
        }], communitySectionLinks: [{
            type: Input
        }], join: [{
            type: Output
        }], leave: [{
            type: Output
        }], toggleFollow: [{
            type: Output
        }], toggleDisclaimer: [{
            type: Output
        }], toggleMobileResourcesView: [{
            type: Output
        }] }); })();
//# sourceMappingURL=data:application/json;base64, 