// Copyright Laserfiche.
// Licensed under the MIT License. See LICENSE in the project root for license information.
import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output } from '@angular/core';
import * as i0 from "@angular/core";
import * as i1 from "../lf-field-base/lf-field-token.service";
import * as i2 from "@angular/common";
import * as i3 from "@angular/material/menu";
export class LfTokenPickerComponent {
    constructor(tokenService) {
        this.tokenService = tokenService;
        this.tokenPicked = new EventEmitter();
        this.tokens = [];
    }
    async ngOnInit() {
        this.tokens = await this.tokenService.getTokensAsync(this.data);
    }
    async onTokenChosen(token) {
        if (token) {
            this.tokenPicked.emit(token.text);
        }
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: LfTokenPickerComponent, deps: [{ token: i1.LfFieldTokenService }], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.14", type: LfTokenPickerComponent, selector: "lf-token-picker-component", inputs: { data: "data" }, outputs: { tokenPicked: "tokenPicked" }, ngImport: i0, template: "<!--Copyright (c) Laserfiche.\r\nLicensed under the MIT License. See LICENSE in the project root for license information.-->\r\n\r\n<button class=\"token-picker-button\" [matMenuTriggerFor]=\"tokenMenu\">\r\n  <span class=\"material-icons token-picker-icon\">\r\n    navigate_next\r\n  </span>\r\n</button>\r\n<mat-menu #tokenMenu=\"matMenu\" class=\"token-picker-dropdown\">\r\n  <button class=\"token-picker-option\" *ngFor=\"let token of tokens\" mat-menu-item\r\n      (click)=\"onTokenChosen(token)\">{{token.friendlyName | async}}</button>\r\n</mat-menu>\r\n", styles: [".token-picker-button{background-color:#fff;border:1px solid #ccc;border-radius:4px;padding:0 5px 2px;width:34px;height:28px;cursor:pointer;line-height:38px}.token-picker-button:hover{background-color:#ddd}.token-picker-button:focus{background-color:#ddd;border:1px solid #ccc;border-radius:4px;outline:none}.token-picker-dropdown{right:0;left:auto;display:inline;float:right;position:absolute;min-width:160px;padding:5px 0;margin:33px 0 0;font-size:14px;list-style:none;background-color:#fff;border:1px solid rgba(0,0,0,.15);border-radius:4px;box-shadow:0 6px 12px #0000002e}.token-picker-option{position:relative;box-sizing:border-box;display:block;text-align:-webkit-match-parent;color:#202020;padding:3px 24px;margin:2px 0 0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;line-height:1.428571429;min-height:unset;height:26px}::ng-deep .mat-mdc-menu-content>.token-picker-option.mat-mdc-menu-item>.mat-mdc-menu-item-text{font-size:14px}::ng-deep .token-picker-dropdown.mat-mdc-menu-panel{min-height:auto}.token-picker-option:hover{background-color:#cce9f180}.token-picker-option:focus{background-color:#cce9f14d}.token-picker-icon{vertical-align:top;font-weight:700}\n"], dependencies: [{ kind: "directive", type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "component", type: i3.MatMenu, selector: "mat-menu", inputs: ["backdropClass", "aria-label", "aria-labelledby", "aria-describedby", "xPosition", "yPosition", "overlapTrigger", "hasBackdrop", "class", "classList"], outputs: ["closed", "close"], exportAs: ["matMenu"] }, { kind: "component", type: i3.MatMenuItem, selector: "[mat-menu-item]", inputs: ["role", "disabled", "disableRipple"], exportAs: ["matMenuItem"] }, { kind: "directive", type: i3.MatMenuTrigger, selector: "[mat-menu-trigger-for], [matMenuTriggerFor]", inputs: ["mat-menu-trigger-for", "matMenuTriggerFor", "matMenuTriggerData", "matMenuTriggerRestoreFocus"], outputs: ["menuOpened", "onMenuOpen", "menuClosed", "onMenuClose"], exportAs: ["matMenuTrigger"] }, { kind: "pipe", type: i2.AsyncPipe, name: "async" }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: LfTokenPickerComponent, decorators: [{
            type: Component,
            args: [{ selector: 'lf-token-picker-component', changeDetection: ChangeDetectionStrategy.OnPush, template: "<!--Copyright (c) Laserfiche.\r\nLicensed under the MIT License. See LICENSE in the project root for license information.-->\r\n\r\n<button class=\"token-picker-button\" [matMenuTriggerFor]=\"tokenMenu\">\r\n  <span class=\"material-icons token-picker-icon\">\r\n    navigate_next\r\n  </span>\r\n</button>\r\n<mat-menu #tokenMenu=\"matMenu\" class=\"token-picker-dropdown\">\r\n  <button class=\"token-picker-option\" *ngFor=\"let token of tokens\" mat-menu-item\r\n      (click)=\"onTokenChosen(token)\">{{token.friendlyName | async}}</button>\r\n</mat-menu>\r\n", styles: [".token-picker-button{background-color:#fff;border:1px solid #ccc;border-radius:4px;padding:0 5px 2px;width:34px;height:28px;cursor:pointer;line-height:38px}.token-picker-button:hover{background-color:#ddd}.token-picker-button:focus{background-color:#ddd;border:1px solid #ccc;border-radius:4px;outline:none}.token-picker-dropdown{right:0;left:auto;display:inline;float:right;position:absolute;min-width:160px;padding:5px 0;margin:33px 0 0;font-size:14px;list-style:none;background-color:#fff;border:1px solid rgba(0,0,0,.15);border-radius:4px;box-shadow:0 6px 12px #0000002e}.token-picker-option{position:relative;box-sizing:border-box;display:block;text-align:-webkit-match-parent;color:#202020;padding:3px 24px;margin:2px 0 0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;line-height:1.428571429;min-height:unset;height:26px}::ng-deep .mat-mdc-menu-content>.token-picker-option.mat-mdc-menu-item>.mat-mdc-menu-item-text{font-size:14px}::ng-deep .token-picker-dropdown.mat-mdc-menu-panel{min-height:auto}.token-picker-option:hover{background-color:#cce9f180}.token-picker-option:focus{background-color:#cce9f14d}.token-picker-icon{vertical-align:top;font-weight:700}\n"] }]
        }], ctorParameters: () => [{ type: i1.LfFieldTokenService }], propDecorators: { data: [{
                type: Input
            }], tokenPicked: [{
                type: Output
            }] } });
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibGYtdG9rZW4tcGlja2VyLmNvbXBvbmVudC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL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