{"version":3,"file":"primeng-terminal.umd.js","sources":["../../src/app/components/terminal/terminalservice.ts","../../src/app/components/terminal/terminal.ts","../../src/app/components/terminal/primeng-terminal.ts"],"sourcesContent":["import { Injectable } from '@angular/core';\nimport { Subject } from 'rxjs';\n\n@Injectable()\nexport class TerminalService {\n    \n    private commandSource = new Subject<string>();\n    private responseSource = new Subject<string>();\n    \n    commandHandler = this.commandSource.asObservable();\n    responseHandler = this.responseSource.asObservable();\n    \n    sendCommand(command: string) {\n        if (command) {\n            this.commandSource.next(command);\n        }\n    }\n    \n    sendResponse(response: string) {\n        if (response) {\n            this.responseSource.next(response);\n        }\n    }\n}","import {NgModule,Component,AfterViewInit,AfterViewChecked,OnDestroy,Input,ElementRef,ChangeDetectionStrategy, ViewEncapsulation, ChangeDetectorRef} from '@angular/core';\nimport {FormsModule} from '@angular/forms';\nimport {CommonModule} from '@angular/common';\nimport {DomHandler} from 'primeng/dom';\nimport {TerminalService} from './terminalservice';\nimport {Subscription}   from 'rxjs';\n\n@Component({\n    selector: 'p-terminal',\n    template: `\n        <div [ngClass]=\"'p-terminal p-component'\" [ngStyle]=\"style\" [class]=\"styleClass\" (click)=\"focus(in)\">\n            <div *ngIf=\"welcomeMessage\">{{welcomeMessage}}</div>\n            <div class=\"p-terminal-content\">\n                <div *ngFor=\"let command of commands\">\n                    <span class=\"p-terminal-prompt\">{{prompt}}</span>\n                    <span class=\"p-terminal-command\">{{command.text}}</span>\n                    <div class=\"p-terminal-response\">{{command.response}}</div>\n                </div>\n            </div>\n            <div class=\"p-terminal-prompt-container\">\n                <span class=\"p-terminal-content-prompt\">{{prompt}}</span>\n                <input #in type=\"text\" [(ngModel)]=\"command\" class=\"p-terminal-input\" autocomplete=\"off\" (keydown)=\"handleCommand($event)\" autofocus>\n            </div>\n        </div>\n    `,\n    changeDetection: ChangeDetectionStrategy.OnPush,\n    encapsulation: ViewEncapsulation.None,\n    styleUrls: ['./terminal.css']\n})\nexport class Terminal implements AfterViewInit,AfterViewChecked,OnDestroy {\n\n    @Input() welcomeMessage: string;\n\n    @Input() prompt: string;\n        \n    @Input() style: any;\n        \n    @Input() styleClass: string;\n            \n    commands: any[] = [];\n    \n    command: string;\n    \n    container: Element;\n    \n    commandProcessed: boolean;\n    \n    subscription: Subscription;\n    \n    constructor(public el: ElementRef, public terminalService: TerminalService, public cd: ChangeDetectorRef) {\n        this.subscription = terminalService.responseHandler.subscribe(response => {\n            this.commands[this.commands.length - 1].response = response;\n            this.commandProcessed = true;\n        });\n    }\n    \n    ngAfterViewInit() {\n        this.container = DomHandler.find(this.el.nativeElement, '.p-terminal')[0];\n    }\n    \n    ngAfterViewChecked() {\n        if (this.commandProcessed) {\n            this.container.scrollTop = this.container.scrollHeight;\n            this.commandProcessed = false;\n        }\n    }\n                \n    @Input()\n    set response(value: string) {\n        if (value) {\n            this.commands[this.commands.length - 1].response = value;\n            this.commandProcessed = true;\n        }\n    }\n    \n    handleCommand(event: KeyboardEvent) {\n        if (event.keyCode == 13) {\n            this.commands.push({text: this.command});\n            this.terminalService.sendCommand(this.command);\n            this.command = '';\n        }\n    }\n    \n    focus(element: HTMLElement) {\n        element.focus();\n    }\n    \n    ngOnDestroy() {\n        if (this.subscription) {\n            this.subscription.unsubscribe();\n        }\n    }\n    \n}\n\n@NgModule({\n    imports: [CommonModule,FormsModule],\n    exports: [Terminal],\n    declarations: [Terminal]\n})\nexport class TerminalModule { }","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":["Subject","Injectable","DomHandler","Component","ChangeDetectionStrategy","ViewEncapsulation","Input","CommonModule","FormsModule","NgModule"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAGA;YAGY,kBAAa,GAAG,IAAIA,YAAO,EAAU,CAAC;YACtC,mBAAc,GAAG,IAAIA,YAAO,EAAU,CAAC;YAE/C,mBAAc,GAAG,IAAI,CAAC,aAAa,CAAC,YAAY,EAAE,CAAC;YACnD,oBAAe,GAAG,IAAI,CAAC,cAA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