{"version":3,"file":"primeng-terminal.mjs","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 private commandSource = new Subject();\n private responseSource = new Subject();\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}\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 * Terminal is a text based user interface.\n * @group Components\n */\n@Component({\n selector: 'p-terminal',\n template: `\n
\n
{{ welcomeMessage }}
\n
\n
\n {{ prompt }}\n {{ command.text }}\n
{{ command.response }}
\n
\n
\n
\n {{ prompt }}\n \n
\n
\n `,\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n styleUrls: ['./terminal.css'],\n host: {\n class: 'p-element'\n }\n})\nexport class Terminal implements AfterViewInit, AfterViewChecked, OnDestroy {\n /**\n * Initial text to display on terminal.\n * @group Props\n */\n @Input() welcomeMessage: string | undefined;\n /**\n * Prompt text for each command.\n * @group Props\n */\n @Input() prompt: string | undefined;\n /**\n * Inline style of the component.\n * @group Props\n */\n @Input() style: { [klass: string]: any } | null | undefined;\n /**\n * Style class of the component.\n * @group Props\n */\n @Input() styleClass: string | undefined;\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@NgModule({\n imports: [CommonModule, FormsModule],\n exports: [Terminal],\n declarations: [Terminal]\n})\nexport class TerminalModule {}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":["i1.TerminalService"],"mappings":";;;;;;;;;MAIa,eAAe,CAAA;AAChB,IAAA,aAAa,GAAG,IAAI,OAAO,EAAU,CAAC;AACtC,IAAA,cAAc,GAAG,IAAI,OAAO,EAAU,CAAC;AAE/C,IAAA,cAAc,GAAG,IAAI,CAAC,aAAa,CAAC,YAAY,EAAE,CAAC;AACnD,IAAA,eAAe,GAAG,IAAI,CAAC,cAAc,CAAC,YAAY,EAAE,CAAC;AAErD,IAAA,WAAW,CAAC,OAAe,EAAA;AACvB,QAAA,IAAI,OAAO,EAAE;AACT,YAAA,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AACpC,SAAA;KACJ;AAED,IAAA,YAAY,CAAC,QAAgB,EAAA;AACzB,QAAA,IAAI,QAAQ,EAAE;AACV,YAAA,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AACtC,SAAA;KAC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