/**
 * @fileoverview added by tsickle
 * Generated from: components/lightbox/lightbox.ts
 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */
/*
    MIT License

    Copyright (c) 2018 Temainfo Software

    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:
    The above copyright notice and this permission notice shall be included in all
    copies or substantial portions of the Software.
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
    SOFTWARE.
*/
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, EventEmitter, HostListener } from '@angular/core';
import { DomSanitizer } from '@angular/platform-browser';
export class TlLightbox {
    /**
     * @param {?} changes
     * @param {?} sanitizer
     */
    constructor(changes, sanitizer) {
        this.changes = changes;
        this.sanitizer = sanitizer;
        this.isOpen = true;
        this.files = [];
        this.close = new EventEmitter();
        this.zoomIn = false;
        this.transform = null;
    }
    /**
     * @return {?}
     */
    onClick() {
        this.close.emit();
    }
    /**
     * @return {?}
     */
    ngOnInit() { }
    /**
     * @param {?} images
     * @param {?} current
     * @return {?}
     */
    init(images, current) {
        this.files = images;
        this.file = !current ? images[0] : current;
        this.changes.detectChanges();
    }
    /**
     * @return {?}
     */
    zoomInOut() {
        this.zoomIn = !this.zoomIn;
        if (!this.zoomIn) {
            this.transform = `translate(0, 0) scale(1)`;
        }
        else {
            this.transform = 'scale(2)';
        }
    }
    /**
     * @param {?} $event
     * @return {?}
     */
    previous($event) {
        this.stopEvent($event);
        if (this.hasImagesOnRight()) {
            this.file = this.files.find((/**
             * @param {?} item
             * @return {?}
             */
            (item) => ((this.file.index - 1) === item.index)));
        }
    }
    /**
     * @param {?} $event
     * @return {?}
     */
    next($event) {
        this.stopEvent($event);
        if (this.hasImagesOnLeft()) {
            this.file = this.files.find((/**
             * @param {?} item
             * @return {?}
             */
            (item) => ((this.file.index + 1) === item.index)));
        }
    }
    /**
     * @param {?} $event
     * @return {?}
     */
    mouseMove($event) {
        /** @type {?} */
        const target = { x: window.innerWidth / 2, y: window.innerHeight / 2 };
        if (this.zoomIn) {
            this.transform = `translate(${-($event.x - target.x)}px, ${-($event.y - target.y)}px) scale(${this.zoomIn ? '2' : '1'})`;
        }
    }
    /**
     * @return {?}
     */
    hasImagesOnLeft() {
        return this.file.index < this.files.length - 1;
    }
    /**
     * @return {?}
     */
    hasImagesOnRight() {
        return this.file.index > 0;
    }
    /**
     * @param {?} $event
     * @param {?} item
     * @return {?}
     */
    selectImage($event, item) {
        this.stopEvent($event);
        this.file = item;
    }
    /**
     * @param {?} $event
     * @return {?}
     */
    stopEvent($event) {
        $event.stopPropagation();
    }
    /**
     * @param {?} file
     * @return {?}
     */
    bypassFile(file) {
        return this.sanitizer.bypassSecurityTrustResourceUrl(file);
    }
}
TlLightbox.decorators = [
    { type: Component, args: [{
                selector: 'tl-lightbox',
                template: "<div class=\"light-box-container\"\n     (click)=\"stopEvent($event)\"\n     [ngClass]=\"zoomIn ? 'zoomIn': 'zoomOut'\">\n  <img class=\"image\"\n       *ngIf=\"file.type === 'image/png' || file.type === 'image/jpeg' || file.type === 'image/bmp' || file.type === 'image/jpg' || file.type === 'image'\"\n       [ngStyle]=\"{ 'transform': transform, 'cursor': zoomIn ? 'zoom-out' : 'zoom-in' }\"\n       [src]=\"bypassFile(file?.file)\" (click)=\"zoomInOut()\" (mousemove)=\"mouseMove($event)\">\n  <iframe *ngIf=\"file.type === 'application/pdf'\" class=\"thumbnail-image\" style=\"border: none;\"  width=\"100%\" height=\"800px\"\n          [src]=bypassFile(file?.file)> </iframe>\n  <div class=\"close-button\" (click)=\"close.emit()\">\n    <tl-icon [lib]=\"'ion'\" [style]=\"'ios'\">close-circle</tl-icon>\n  </div>\n</div>\n\n\n<div class=\"image-info\">\n  <h3 *ngIf=\"file?.title\">{{ file?.title }}</h3>\n  <p>{{ file?.description}}</p>\n</div>\n<div class=\"light-box-controls\">\n  <tl-icon class=\"arrow left\" *ngIf=\"files.length > 1 && hasImagesOnRight()\" (click)=\"previous($event)\" [lib]=\"'ion'\"\n           [style]=\"'ios'\">arrow-dropleft-circle\n  </tl-icon>\n  <tl-icon class=\"arrow right\" *ngIf=\"files.length > 1 && hasImagesOnLeft()\" (click)=\"next($event)\" [lib]=\"'ion'\"\n           [style]=\"'ios'\">arrow-dropright-circle\n  </tl-icon>\n</div>\n<div class=\"footer-images\" (click)=\"stopEvent($event)\">\n  <ng-container *ngFor=\"let item of files\">\n    <ng-container *ngIf=\"item.type === 'image/png' || item.type === 'image/jpeg' || item.type === 'image/bmp' || item.type === 'image/jpg' || item.type === 'image'\">\n      <img class=\"thumbnail\" [class.selected]=\"item?.index === file?.index\"\n           (click)=\"selectImage($event, item)\" [src]=\"item?.file\">\n    </ng-container>\n    <ng-container *ngIf=\"item.type === 'application/pdf'\" >\n      <div class=\"thumbnail\" [class.selected]=\"item?.index === file?.index\" (click)=\"selectImage($event, item)\">\n        <tl-icon  style=\"margin-right: 5px\" [lib]=\"'fa'\" [style]=\"'fas'\" [color]=\"'#ec7e7e'\" [size]=\"'40px'\">file-pdf</tl-icon>\n      </div>\n    </ng-container>\n  </ng-container>\n</div>\n",
                changeDetection: ChangeDetectionStrategy.OnPush,
                styles: [":host{height:100%;width:100%}.light-box-container,:host{align-items:center;display:flex;flex-flow:column;justify-content:center}.light-box-container{background:transparent;height:70vh;overflow:hidden;position:relative;transition:transform .25s ease;width:70vw;z-index:1000}.light-box-container>.image{-moz-user-select:none;-ms-user-select:none;-webkit-user-select:none;height:100%;user-select:none}.light-box-container>.close-button{color:#989898;cursor:pointer;font-size:50px;position:fixed;right:20px;top:20px}.light-box-container.zoomIn{transform:scale(2)}.light-box-container.zoomOut{transform:scale(1)}.light-box-controls{font-size:3em;z-index:1000}.light-box-controls .arrow{color:#989898;cursor:pointer;position:fixed;top:calc(50vh - 64px)}.light-box-controls .arrow.left{left:7%}.light-box-controls .arrow.right{right:7%}.image-info{color:#fff;font-size:16px;margin:20px 0;text-align:center}.footer-images{background:rgba(0,0,0,.69);bottom:0;height:100px;position:absolute;width:100%}.footer-images,.footer-images .thumbnail{align-items:center;display:flex;justify-content:center}.footer-images .thumbnail{border:1px solid #5d5b5b;height:80px;margin:0 5px;width:80px}.footer-images .thumbnail.selected{border:1px solid #fff!important}.footer-images .thumbnail:hover{cursor:pointer;opacity:.8}"]
            }] }
];
/** @nocollapse */
TlLightbox.ctorParameters = () => [
    { type: ChangeDetectorRef },
    { type: DomSanitizer }
];
TlLightbox.propDecorators = {
    onClick: [{ type: HostListener, args: ['click',] }]
};
if (false) {
    /** @type {?} */
    TlLightbox.prototype.isOpen;
    /** @type {?} */
    TlLightbox.prototype.files;
    /** @type {?} */
    TlLightbox.prototype.file;
    /** @type {?} */
    TlLightbox.prototype.close;
    /** @type {?} */
    TlLightbox.prototype.zoomIn;
    /** @type {?} */
    TlLightbox.prototype.transform;
    /**
     * @type {?}
     * @private
     */
    TlLightbox.prototype.changes;
    /**
     * @type {?}
     * @private
     */
    TlLightbox.prototype.sanitizer;
}
//# sourceMappingURL=data:application/json;base64, 