!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("rxjs"),require("@angular/platform-browser"),require("@angular/common")):"function"==typeof define&&define.amd?define("ngx-hotkeys-vnc",["exports","@angular/core","rxjs","@angular/platform-browser","@angular/common"],t):t((e=e||self)["ngx-hotkeys-vnc"]={},e.ng.core,e.rxjs,e.ng.platformBrowser,e.ng.common)}(this,(function(e,t,n,o,i){"use strict";
/*! *****************************************************************************
    Copyright (c) Microsoft Corporation.

    Permission to use, copy, modify, and/or distribute this software for any
    purpose with or without fee is hereby granted.

    THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
    REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
    AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
    INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
    LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
    OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
    PERFORMANCE OF THIS SOFTWARE.
    ***************************************************************************** */var r=function(){return(r=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)};function s(e,t,n,o){var i,r=arguments.length,s=r<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,o);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(r<3?i(s):r>3?i(t,n,s):i(t,n))||s);return r>3&&s&&Object.defineProperty(t,n,s),s}function a(e,t){return function(n,o){t(n,o,e)}}function c(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}var h=new t.InjectionToken("HotkeyOptions"),p={disableCheatSheet:!1,cheatSheetTitle:"Keyboard Shortcuts:",cheatSheetHotkey:"shift.?",cheatSheetHotkeyDescription:"Show / hide this help menu",cheatSheetCloseEsc:!1,cheatSheetCloseEscDescription:"Hide this help menu"},l=function(){function e(e,t,o){var i=this;this.eventManager=e,this.config=t,this.registeredHotkeys=new Set,this.pausedHotkeys=new Set,this._cheatSheetToggled=new n.Subject,this.bindingSubscriptions=new Map,this.document=o,this.defaults={element:this.document},this.configuration=r(r({},p),this.config),this.configuration.disableCheatSheet||this.register({combo:this.configuration.cheatSheetHotkey,handler:function(){i._cheatSheetToggled.next(!0)},description:this.configuration.cheatSheetHotkeyDescription}),this.configuration.cheatSheetCloseEsc&&this.register({combo:"esc",handler:function(){i._cheatSheetToggled.next(!1)},description:this.configuration.cheatSheetCloseEscDescription})}return Object.defineProperty(e.prototype,"hotkeys",{get:function(){return Array.from(this.registeredHotkeys)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"cheatSheetToggled",{get:function(){return this._cheatSheetToggled.asObservable().pipe(n.share())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"options",{get:function(){return this.configuration},enumerable:!0,configurable:!0}),e.prototype.register=function(e,t){var n=this;void 0===t&&(t=!1);var o=[].concat(e);t&&(o=Array.from(this.pausedHotkeys)),o.forEach((function(e){t&&n.pausedHotkeys.delete(e),n.registeredHotkeys.add(e),n.bindingSubscriptions.set(e.combo,n.bindToEventManager(e).subscribe((function(){e.handler()})))}))},e.prototype.unregister=function(e,t){var n=this;void 0===t&&(t=!1),[].concat(e).forEach((function(e){n.registeredHotkeys.delete(e),t&&n.pausedHotkeys.add(e),n.unbindFromEventManager(e)}))},e.prototype.get=function(e){return this.hotkeys.filter((function(t){return t.combo===e}))},e.prototype.pause=function(e){if(!e)return this.pause(this.hotkeys);var t=[].concat(e);this.unregister(t,!0)},e.prototype.unpause=function(e){if(!e)return this.unpause(this.hotkeys);var t=[].concat(e);this.register(t,!0)},e.prototype.reset=function(){var e=this;this.registeredHotkeys.forEach((function(t){return e.unbindFromEventManager(t)})),this.registeredHotkeys.clear(),this.pausedHotkeys.clear()},e.prototype.ngOnDestroy=function(){this.reset()},e.prototype.bindToEventManager=function(e){var t=this,o=r(r({},this.defaults),e),i="keydown."+o.combo.toString().replace("+",".");return new n.Observable((function(e){var n=t.eventManager.addEventListener(o.element,i,(function(t){t.preventDefault(),e.next(t)}));return function(){n()}}))},e.prototype.unbindFromEventManager=function(e){var t=r(r({},this.defaults),e),n=this.bindingSubscriptions.get(t.combo);n&&!n.closed&&(n.unsubscribe(),this.bindingSubscriptions.delete(t.combo))},e.ctorParameters=function(){return[{type:o.EventManager},{type:void 0,decorators:[{type:t.Inject,args:[h]}]},{type:void 0,decorators:[{type:t.Inject,args:[i.DOCUMENT]}]}]},e.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e(t.ɵɵinject(o.EventManager),t.ɵɵinject(h),t.ɵɵinject(i.DOCUMENT))},token:e,providedIn:"root"}),e=s([t.Injectable({providedIn:"root"}),a(1,t.Inject(h)),a(2,t.Inject(i.DOCUMENT)),c("design:paramtypes",[o.EventManager,Object,Object])],e)}(),u=function(){function e(e){this.hotkeysService=e,this.helpVisible=!1,this._map={meta:"⌘",shift:"⇧",left:"←",right:"→",up:"↑",down:"↓",return:"⏎",backspace:"⌫"},this.title=this.hotkeysService.options.cheatSheetTitle||this.title}return e.prototype.ngOnInit=function(){var e=this;this._subscription=this.hotkeysService.cheatSheetToggled.subscribe((function(t){!1!==t&&(e.hotkeys=e.hotkeysService.hotkeys.filter((function(e){return e.description}))),!1===t?e.helpVisible=!1:e.toggleCheatSheet()}))},e.prototype.formatHotkey=function(e){for(var t=(Array.isArray(e.combo)?e.combo[0]:e.combo).split(/[\s]/),n=0;n<t.length;n++)t[n]=this.symbolize(t[n]);return t},e.prototype.symbolize=function(e){for(var t=e.split("."),n=0;n<t.length;n++)"mod"===t[n]&&(window.navigator&&window.navigator.platform.indexOf("Mac")>=0?t[n]="meta":t[n]="ctrl"),t[n]=this._map[t[n]]||t[n];return t.join(" + ")},e.prototype.ngOnDestroy=function(){this._subscription&&!this._subscription.closed&&this._subscription.unsubscribe()},e.prototype.toggleCheatSheet=function(){this.helpVisible=!this.helpVisible},e.ctorParameters=function(){return[{type:l}]},s([t.Input(),c("design:type",String)],e.prototype,"title",void 0),e=s([t.Component({selector:"ngx-cheatsheet",template:'<div class="ngx-cheatsheet fade" [ngClass]="{\'in\': helpVisible}" style="display:none">\n  <div class="ngx-cheatsheet__hotkeys">\n    <h4 class="ngx-cheatsheet__hotkeys__title">{{ title }}</h4>\n    <table>\n      <tbody>\n        <tr *ngFor="let hotkey of hotkeys">\n          <td class="ngx-cheatsheet__hotkeys__keys">\n            <span class="ngx-cheatsheet__hotkeys__keys__key">{{ formatHotkey(hotkey) }}</span>\n          </td>\n          <td class="ngx-cheatsheet__hotkeys__keys__text">{{ hotkey.description }}</td>\n        </tr>\n      </tbody>\n    </table>\n    <div class="ngx-cheatsheet__hotkeys__close" (click)="toggleCheatSheet()">&#215;</div>\n  </div>\n</div>',styles:[".ngx-cheatsheet{display:table!important;position:fixed;width:100%;height:100%;top:0;left:0;color:#333;font-size:1em;background-color:rgba(255,255,255,.9)}.ngx-cheatsheet.fade{z-index:-1024;visibility:hidden;opacity:0;transition:opacity .15s linear}.ngx-cheatsheet.fade.in{z-index:10002;visibility:visible;opacity:1}.ngx-cheatsheet__hotkeys{width:100%;height:100%;display:table-cell;vertical-align:middle}.ngx-cheatsheet__hotkeys__title{font-weight:700;text-align:center;font-size:1.2em}.ngx-cheatsheet__hotkeys table{margin:auto;color:#333}.ngx-cheatsheet__hotkeys__keys{padding:5px;text-align:right}.ngx-cheatsheet__hotkeys__keys__key{display:inline-block;color:#fff;background-color:#333;border:1px solid #333;border-radius:5px;text-align:center;margin-right:5px;box-shadow:inset 0 1px 0 #666,0 1px 0 #bbb;padding:5px 9px;font-size:1em}.ngx-cheatsheet__hotkeys__keys__text{padding-left:10px;font-size:1em}.ngx-cheatsheet__hotkeys__close{position:fixed;top:20px;right:20px;font-size:2em;font-weight:700;padding:5px 10px;border:1px solid #ddd;border-radius:5px;min-height:45px;min-width:45px;text-align:center;cursor:pointer}@media all and (max-width:500px){.ngx-cheatsheet__hotkeys{font-size:.8em}}@media all and (min-width:750px){.ngx-cheatsheet__hotkeys{font-size:1.2em}}"]}),c("design:paramtypes",[l])],e)}(),d=function(){function e(){}var n;return n=e,e.forRoot=function(e){return{ngModule:n,providers:[l,{provide:h,useValue:e}]}},e=n=s([t.NgModule({imports:[i.CommonModule],declarations:[u],exports:[u]})],e)}();e.NgxCheatsheetComponent=u,e.NgxHotkeysModule=d,e.NgxHotkeysService=l,e.ɵa=h,Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=ngx-hotkeys-vnc.umd.min.js.map