import { Component, EventEmitter, Input, Output } from '@angular/core';
import { SessionsService } from '@aztrix/sdk';
import { ReplaySubject } from 'rxjs';
import { mergeMap } from 'rxjs/operators';
import * as i0 from "@angular/core";
import * as i1 from "@aztrix/sdk";
import * as i2 from "@aztrix/components/button";
import * as i3 from "@aztrix/icons";
import * as i4 from "@aztrix/components/copy-text";
import * as i5 from "@aztrix/helpers";
export class TokenListCellComponent {
    constructor(_sessions) {
        this._sessions = _sessions;
        this.didClickButton = new EventEmitter();
        this.session$ = new ReplaySubject(1);
        this.authToken$ = this.session$.pipe(mergeMap((session) => this._sessions.authTokenForSession(session.sessionId)));
    }
    ngOnChanges(changes) {
        if (changes.session && this.session) {
            this.session$.next(this.session);
        }
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: TokenListCellComponent, deps: [{ token: i1.SessionsService }], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.12", type: TokenListCellComponent, selector: "ax-token-list-cell", inputs: { session: "session" }, outputs: { didClickButton: "didClickButton" }, usesOnChanges: true, ngImport: i0, template: "<div class=\"key-wrapper\">\n  <div class=\"key-name\">\n    {{ session.sessionInfo?.name }}\n  </div>\n  <div class=\"key-date\">\n    {{ session.timestamp | formatDateTimeFromNow }}\n  </div>\n  <div class=\"key-hash\">\n    <ax-copy-text [value]=\"session.sessionId\" [secret]=\"true\"></ax-copy-text>\n  </div>\n  <button class=\"expire\" axButton icon-button (click)=\"didClickButton.emit()\">\n    <ax-icon name=\"delete-outline\" class=\"icon\"></ax-icon>\n  </button>\n</div>\n", styles: [".key-wrapper{display:grid;grid-template-columns:1fr 1fr max-content;grid-template-areas:\"name date expire\" \"hash hash expire\";align-items:center;width:100%;padding:.75rem 1rem;grid-gap:.5rem;background-color:#fff;border-bottom:1px solid #d7dde4}.key-name{grid-area:name;font-weight:700}.key-hash{grid-area:hash}.key-copy{grid-area:copy}.expire{grid-area:expire;grid-row-start:1;grid-row-end:3}.key-date{grid-area:date;justify-self:flex-end;color:#7a8692;font-weight:400}\n"], dependencies: [{ kind: "directive", type: i2.ButtonDirective, selector: "[axButton]", inputs: ["color", "labelHideMobile", "smallButton", "bigButton", "fullWidth", "filled", "outline", "icon-button", "hoverLabel", "hover", "lowercase", "disabled"] }, { kind: "component", type: i3.IconComponent, selector: "ax-icon", inputs: ["name", "inline"] }, { kind: "component", type: i4.CopyTextComponent, selector: "ax-copy-text", inputs: ["value", "secret", "code"] }, { kind: "pipe", type: i5.FormatDateTimeFromNowPipe, name: "formatDateTimeFromNow" }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: TokenListCellComponent, decorators: [{
            type: Component,
            args: [{ selector: 'ax-token-list-cell', template: "<div class=\"key-wrapper\">\n  <div class=\"key-name\">\n    {{ session.sessionInfo?.name }}\n  </div>\n  <div class=\"key-date\">\n    {{ session.timestamp | formatDateTimeFromNow }}\n  </div>\n  <div class=\"key-hash\">\n    <ax-copy-text [value]=\"session.sessionId\" [secret]=\"true\"></ax-copy-text>\n  </div>\n  <button class=\"expire\" axButton icon-button (click)=\"didClickButton.emit()\">\n    <ax-icon name=\"delete-outline\" class=\"icon\"></ax-icon>\n  </button>\n</div>\n", styles: [".key-wrapper{display:grid;grid-template-columns:1fr 1fr max-content;grid-template-areas:\"name date expire\" \"hash hash expire\";align-items:center;width:100%;padding:.75rem 1rem;grid-gap:.5rem;background-color:#fff;border-bottom:1px solid #d7dde4}.key-name{grid-area:name;font-weight:700}.key-hash{grid-area:hash}.key-copy{grid-area:copy}.expire{grid-area:expire;grid-row-start:1;grid-row-end:3}.key-date{grid-area:date;justify-self:flex-end;color:#7a8692;font-weight:400}\n"] }]
        }], ctorParameters: () => [{ type: i1.SessionsService }], propDecorators: { session: [{
                type: Input
            }], didClickButton: [{
                type: Output
            }] } });
//# sourceMappingURL=data:application/json;base64,e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