<commit_before>import {
    Component,
    Directive,
    ElementRef,
    Input,
    OnChanges,
    OnInit,
    Optional,
    SimpleChanges
} from '@angular/core';
import { ThemePalette } from '@ptsecurity/mosaic/core';

import { McSidepanelRef } from './sidepanel-ref';
import { McSidepanelService } from './sidepanel.service';


/**
 * Button that will close the current sidepanel.
 */
@Directive({
    selector: 'button[mc-sidepanel-close], button[mcSidepanelClose]',
    host: {
        '(click)': 'sidepanelRef.close(sidepanelResult)',
        class: 'mc-sidepanel-close'
    }
})
export class McSidepanelClose implements OnInit, OnChanges {
    @Input('mc-sidepanel-close') sidepanelResult: any;

    @Input('mcSidepanelClose') mcSidepanelClose: any;

    constructor(
        @Optional() public sidepanelRef: McSidepanelRef,
        private elementRef: ElementRef<HTMLElement>,
        private sidepanelService: McSidepanelService
    ) {}

    ngOnInit() {
        if (!this.sidepanelRef) {
            // When this directive is included in a sidepanel via TemplateRef (rather than being
            // in a Component), the SidepanelRef isn't available via injection because embedded
            // views cannot be given a custom injector. Instead, we look up the SidepanelRef by
            // ID.
            // This must occur in `onInit`, as the ID binding for the sidepanel container won't
            // be resolved at constructor time. We use setTimeout by same reason.
            setTimeout(() => {
                this.sidepanelRef = getClosestSidepanel(this.elementRef, this.sidepanelService.openedSidepanels)!;
            });
        }
    }

    ngOnChanges(changes: SimpleChanges) {
        const proxiedChange = changes.mcSidepanelClose || changes.sidepanelResult;

        if (proxiedChange) {
            this.sidepanelResult = proxiedChange.currentValue;
        }
    }
}

/**
 * Header of a sidepanel.
 */
@Component({
    selector: 'mc-sidepanel-header',
    template: `
        <div class="mc-sidepanel-title">
            <ng-content></ng-content>
        </div>
        <button *ngIf="closeable" mc-sidepanel-close>
            <span class="mc-sidepanel-close-x">
                <i mc-icon="mc-close-L_16" class="mc-icon mc-icon_light" [color]="themePalette.Primary"></i>
            </span>
        </button>
    `,
    host: {<commit_msg>fix(sidepanel): use second color for close icon (#UIM-892) (#833)<commit_after>import {
    Component,
    Directive,
    ElementRef,
    Input,
    OnChanges,
    OnInit,
    Optional,
    SimpleChanges
} from '@angular/core';
import { ThemePalette } from '@ptsecurity/mosaic/core';

import { McSidepanelRef } from './sidepanel-ref';
import { McSidepanelService } from './sidepanel.service';


/**
 * Button that will close the current sidepanel.
 */
@Directive({
    selector: 'button[mc-sidepanel-close], button[mcSidepanelClose]',
    host: {
        '(click)': 'sidepanelRef.close(sidepanelResult)',
        class: 'mc-sidepanel-close'
    }
})
export class McSidepanelClose implements OnInit, OnChanges {
    @Input('mc-sidepanel-close') sidepanelResult: any;

    @Input('mcSidepanelClose') mcSidepanelClose: any;

    constructor(
        @Optional() public sidepanelRef: McSidepanelRef,
        private elementRef: ElementRef<HTMLElement>,
        private sidepanelService: McSidepanelService
    ) {}

    ngOnInit() {
        if (!this.sidepanelRef) {
            // When this directive is included in a sidepanel via TemplateRef (rather than being
            // in a Component), the SidepanelRef isn't available via injection because embedded
            // views cannot be given a custom injector. Instead, we look up the SidepanelRef by
            // ID.
            // This must occur in `onInit`, as the ID binding for the sidepanel container won't
            // be resolved at constructor time. We use setTimeout by same reason.
            setTimeout(() => {
                this.sidepanelRef = getClosestSidepanel(this.elementRef, this.sidepanelService.openedSidepanels)!;
            });
        }
    }

    ngOnChanges(changes: SimpleChanges) {
        const proxiedChange = changes.mcSidepanelClose || changes.sidepanelResult;

        if (proxiedChange) {
            this.sidepanelResult = proxiedChange.currentValue;
        }
    }
}

/**
 * Header of a sidepanel.
 */
@Component({
    selector: 'mc-sidepanel-header',
    template: `
        <div class="mc-sidepanel-title">
            <ng-content></ng-content>
        </div>
        <button *ngIf="closeable" mc-sidepanel-close>
            <span class="mc-sidepanel-close-x">
                <i mc-icon="mc-close-L_16" class="mc-icon mc-icon_light" [color]="themePalette.Second"></i>
            </span>
        </button>
    `,
    host: {
{'fraction_non_alphanumeric': 0.11544071681600333, 'fraction_numerical': 0.002083767451552407, 'mean_word_length': 2.5346097201767304, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3827014', 'n_tokens_mistral': 1404, 'n_tokens_neox': 1362, 'n_words': 346}