!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("@angular/common"),require("primeng/dom"),require("primeng/api"),require("primeng/ripple"),require("@angular/router"),require("rxjs"),require("rxjs/operators")):"function"==typeof define&&define.amd?define("primeng/contextmenu",["exports","@angular/core","@angular/common","primeng/dom","primeng/api","primeng/ripple","@angular/router","rxjs","rxjs/operators"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).primeng=e.primeng||{},e.primeng.contextmenu={}),e.ng.core,e.ng.common,e.primeng.dom,e.primeng.api,e.primeng.ripple,e.ng.router,e.rxjs,e.rxjs.operators)}(this,(function(e,t,n,i,r,o,l,s,a){"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.
***************************************************************************** */Object.create;function c(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],i=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&i>=e.length&&(e=void 0),{value:e&&e[i++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}Object.create;var u=function(){function e(e){this.leafClick=new t.EventEmitter,this.contextMenu=e}return e.prototype.ngOnInit=function(){var e=this;this.activeItemKeyChangeSubscription=this.contextMenu.contextMenuService.activeItemKeyChange$.pipe(a.takeUntil(this.contextMenu.ngDestroy$)).subscribe((function(t){e.activeItemKey=t,e.isActive(e.parentItemKey)&&i.DomHandler.hasClass(e.sublistViewChild.nativeElement,"p-submenu-list-active")&&e.contextMenu.positionSubmenu(e.sublistViewChild.nativeElement),e.contextMenu.cd.markForCheck()}))},e.prototype.onItemMouseEnter=function(e,t,n){if(this.hideTimeout&&(clearTimeout(this.hideTimeout),this.hideTimeout=null),!t.disabled){if(t.items){var r=i.DomHandler.findSingle(e.currentTarget,".p-submenu-list");i.DomHandler.addClass(r,"p-submenu-list-active")}this.contextMenu.contextMenuService.changeKey(n)}},e.prototype.onItemMouseLeave=function(e,t){t.disabled||this.contextMenu.el.nativeElement.contains(e.toElement)&&(t.items&&this.contextMenu.removeActiveFromSubLists(e.currentTarget),this.root||this.contextMenu.contextMenuService.changeKey(this.parentItemKey))},e.prototype.onItemClick=function(e,t,n,r){if(t.disabled)e.preventDefault();else{if(t.url||t.routerLink||e.preventDefault(),t.command&&t.command({originalEvent:e,item:t}),t.items){var o=i.DomHandler.findSingle(n,".p-submenu-list");o&&(this.isActive(r)&&i.DomHandler.hasClass(o,"p-submenu-list-active")?this.contextMenu.removeActiveFromSubLists(n):i.DomHandler.addClass(o,"p-submenu-list-active"),this.contextMenu.contextMenuService.changeKey(r))}t.items||this.onLeafClick()}},e.prototype.onLeafClick=function(){this.root&&this.contextMenu.hide(),this.leafClick.emit()},e.prototype.getKey=function(e){return this.root?String(e):this.parentItemKey+"_"+e},e.prototype.isActive=function(e){return this.activeItemKey&&(this.activeItemKey.startsWith(e+"_")||this.activeItemKey===e)},e}();u.decorators=[{type:t.Component,args:[{selector:"p-contextMenuSub",template:'\n
\n ',encapsulation:t.ViewEncapsulation.None}]}],u.ctorParameters=function(){return[{type:void 0,decorators:[{type:t.Inject,args:[t.forwardRef((function(){return d}))]}]}]},u.propDecorators={item:[{type:t.Input}],root:[{type:t.Input}],parentItemKey:[{type:t.Input}],leafClick:[{type:t.Output}],sublistViewChild:[{type:t.ViewChild,args:["sublist"]}],menuitemViewChild:[{type:t.ViewChild,args:["menuitem"]}]};var d=function(){function e(e,n,i,r,o){this.el=e,this.renderer=n,this.cd=i,this.zone=r,this.contextMenuService=o,this.autoZIndex=!0,this.baseZIndex=0,this.triggerEvent="contextmenu",this.onShow=new t.EventEmitter,this.onHide=new t.EventEmitter,this.ngDestroy$=new s.Subject}return e.prototype.ngAfterViewInit=function(){var e=this;if(this.global){var t=this.el?this.el.nativeElement.ownerDocument:"document";this.triggerEventListener=this.renderer.listen(t,this.triggerEvent,(function(t){e.show(t),t.preventDefault()}))}else this.target&&(this.triggerEventListener=this.renderer.listen(this.target,this.triggerEvent,(function(t){e.show(t),t.preventDefault(),t.stopPropagation()})));this.appendTo&&("body"===this.appendTo?document.body.appendChild(this.containerViewChild.nativeElement):i.DomHandler.appendChild(this.containerViewChild.nativeElement,this.appendTo))},e.prototype.show=function(e){this.clearActiveItem(),this.position(e),this.moveOnTop(),this.containerViewChild.nativeElement.style.display="block",i.DomHandler.fadeIn(this.containerViewChild.nativeElement,250),this.bindGlobalListeners(),e&&e.preventDefault(),this.onShow.emit()},e.prototype.hide=function(){this.containerViewChild.nativeElement.style.display="none",this.unbindGlobalListeners(),this.onHide.emit()},e.prototype.moveOnTop=function(){this.autoZIndex&&(this.containerViewChild.nativeElement.style.zIndex=String(this.baseZIndex+ ++i.DomHandler.zindex))},e.prototype.toggle=function(e){this.containerViewChild.nativeElement.offsetParent?this.hide():this.show(e)},e.prototype.position=function(e){if(e){var t=e.pageX+1,n=e.pageY+1,r=this.containerViewChild.nativeElement.offsetParent?this.containerViewChild.nativeElement.offsetWidth:i.DomHandler.getHiddenElementOuterWidth(this.containerViewChild.nativeElement),o=this.containerViewChild.nativeElement.offsetParent?this.containerViewChild.nativeElement.offsetHeight:i.DomHandler.getHiddenElementOuterHeight(this.containerViewChild.nativeElement),l=i.DomHandler.getViewport();t+r-document.body.scrollLeft>l.width&&(t-=r),n+o-document.body.scrollTop>l.height&&(n-=o),tn.height-i.DomHandler.calculateScrollbarHeight()?(e.style.removeProperty("top"),e.style.bottom="0px"):(e.style.removeProperty("bottom"),e.style.top="0px"),parseInt(a.left)+l+r>n.width-i.DomHandler.calculateScrollbarWidth()?e.style.left=-r+"px":e.style.left=l+"px"},e.prototype.isItemMatched=function(e){return i.DomHandler.hasClass(e,"p-menuitem")&&!i.DomHandler.hasClass(e.children[0],"p-disabled")},e.prototype.findNextItem=function(e,t){var n=e.nextElementSibling;if(n)return this.isItemMatched(n)?n:this.findNextItem(n,t);var i=e.parentElement.children[0];return this.isItemMatched(i)?i:t?null:this.findNextItem(i,!0)},e.prototype.findPrevItem=function(e,t){var n=e.previousElementSibling;if(n)return this.isItemMatched(n)?n:this.findPrevItem(n,t);var i=e.parentElement.children[e.parentElement.children.length-1];return this.isItemMatched(i)?i:t?null:this.findPrevItem(i,!0)},e.prototype.getActiveItem=function(){var e=this.contextMenuService.activeItemKey;return null==e?null:i.DomHandler.findSingle(this.containerViewChild.nativeElement,'.p-menuitem[data-ik="'+e+'"]')},e.prototype.clearActiveItem=function(){this.contextMenuService.activeItemKey&&(this.removeActiveFromSubLists(this.containerViewChild.nativeElement),this.contextMenuService.reset())},e.prototype.removeActiveFromSubLists=function(e){var t,n,r=i.DomHandler.find(e,".p-submenu-list-active");try{for(var o=c(r),l=o.next();!l.done;l=o.next()){var s=l.value;i.DomHandler.removeClass(s,"p-submenu-list-active")}}catch(e){t={error:e}}finally{try{l&&!l.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}},e.prototype.removeActiveFromSublist=function(e){e&&(i.DomHandler.findSingle(e,".p-submenu-list")&&i.DomHandler.hasClass(e,"p-submenu-list-active")&&i.DomHandler.removeClass(e,"p-submenu-list-active"))},e.prototype.bindGlobalListeners=function(){var e=this;if(!this.documentClickListener){var t=this.el?this.el.nativeElement.ownerDocument:"document";this.documentClickListener=this.renderer.listen(t,"click",(function(t){e.containerViewChild.nativeElement.offsetParent&&e.isOutsideClicked(t)&&!t.ctrlKey&&2!==t.button&&e.hide()}))}if(this.zone.runOutsideAngular((function(){e.windowResizeListener||(e.windowResizeListener=e.onWindowResize.bind(e),window.addEventListener("resize",e.windowResizeListener))})),!this.documentKeydownListener){t=this.el?this.el.nativeElement.ownerDocument:"document";this.documentKeydownListener=this.renderer.listen(t,"keydown",(function(t){var n=e.getActiveItem();switch(t.key){case"ArrowDown":if(n)e.removeActiveFromSublist(n),n=e.findNextItem(n);else{var r=i.DomHandler.findSingle(e.containerViewChild.nativeElement,".p-menuitem-link").parentElement;n=e.isItemMatched(r)?r:e.findNextItem(r)}n&&e.contextMenuService.changeKey(n.getAttribute("data-ik")),t.preventDefault();break;case"ArrowUp":if(n)e.removeActiveFromSublist(n),n=e.findPrevItem(n);else{var o=(l=i.DomHandler.findSingle(e.containerViewChild.nativeElement,"ul")).children[l.children.length-1];n=e.isItemMatched(o)?o:e.findPrevItem(o)}n&&e.contextMenuService.changeKey(n.getAttribute("data-ik")),t.preventDefault();break;case"ArrowRight":if(n)(l=i.DomHandler.findSingle(n,".p-submenu-list"))&&(i.DomHandler.addClass(l,"p-submenu-list-active"),(n=i.DomHandler.findSingle(l,".p-menuitem-link:not(.p-disabled)").parentElement)&&e.contextMenuService.changeKey(n.getAttribute("data-ik")));t.preventDefault();break;case"ArrowLeft":var l;if(n)(l=n.parentElement)&&i.DomHandler.hasClass(l,"p-submenu-list-active")&&(i.DomHandler.removeClass(l,"p-submenu-list-active"),(n=l.parentElement.parentElement)&&e.contextMenuService.changeKey(n.getAttribute("data-ik")));t.preventDefault();break;case"Escape":e.hide(),t.preventDefault();break;case"Enter":n&&e.handleItemClick(t,e.findModelItemFromKey(e.contextMenuService.activeItemKey),n),t.preventDefault()}}))}},e.prototype.findModelItemFromKey=function(e){var t=this;return null!=e&&this.model?e.split("_").reduce((function(e,n){return e?e.items[n]:t.model[n]}),null):null},e.prototype.handleItemClick=function(e,t,n){if(t&&!t.disabled){if(t.command&&t.command({originalEvent:e,item:t}),t.items){var r=i.DomHandler.findSingle(n,".p-submenu-list");r&&(i.DomHandler.hasClass(r,"p-submenu-list-active")?this.removeActiveFromSubLists(n):(i.DomHandler.addClass(r,"p-submenu-list-active"),this.positionSubmenu(r)))}t.items||this.hide()}},e.prototype.unbindGlobalListeners=function(){this.documentClickListener&&(this.documentClickListener(),this.documentClickListener=null),this.windowResizeListener&&(window.removeEventListener("resize",this.windowResizeListener),this.windowResizeListener=null),this.documentKeydownListener&&(this.documentKeydownListener(),this.documentKeydownListener=null)},e.prototype.onWindowResize=function(e){this.containerViewChild.nativeElement.offsetParent&&this.hide()},e.prototype.isOutsideClicked=function(e){return!(this.containerViewChild.nativeElement.isSameNode(e.target)||this.containerViewChild.nativeElement.contains(e.target))},e.prototype.ngOnDestroy=function(){this.unbindGlobalListeners(),this.triggerEventListener&&this.triggerEventListener(),this.appendTo&&this.el.nativeElement.appendChild(this.containerViewChild.nativeElement),this.ngDestroy$.next(!0),this.ngDestroy$.complete()},e}();d.decorators=[{type:t.Component,args:[{selector:"p-contextMenu",template:'\n \n ',changeDetection:t.ChangeDetectionStrategy.OnPush,encapsulation:t.ViewEncapsulation.None,styles:[".p-contextmenu{display:none;position:absolute}.p-contextmenu ul{list-style:none;margin:0;padding:0}.p-contextmenu .p-submenu-list{display:none;min-width:100%;position:absolute;z-index:1}.p-contextmenu .p-menuitem-link{align-items:center;cursor:pointer;display:flex;overflow:hidden;position:relative;text-decoration:none}.p-contextmenu .p-menuitem-text{line-height:1}.p-contextmenu .p-menuitem{position:relative}.p-contextmenu .p-menuitem-link .p-submenu-icon{margin-left:auto}.p-contextmenu .p-menuitem-active>p-contextmenusub>.p-submenu-list.p-submenu-list-active{display:block!important}"]}]}],d.ctorParameters=function(){return[{type:t.ElementRef},{type:t.Renderer2},{type:t.ChangeDetectorRef},{type:t.NgZone},{type:r.ContextMenuService}]},d.propDecorators={model:[{type:t.Input}],global:[{type:t.Input}],target:[{type:t.Input}],style:[{type:t.Input}],styleClass:[{type:t.Input}],appendTo:[{type:t.Input}],autoZIndex:[{type:t.Input}],baseZIndex:[{type:t.Input}],triggerEvent:[{type:t.Input}],onShow:[{type:t.Output}],onHide:[{type:t.Output}],containerViewChild:[{type:t.ViewChild,args:["container"]}]};var m=function(){};m.decorators=[{type:t.NgModule,args:[{imports:[n.CommonModule,l.RouterModule,o.RippleModule],exports:[d,l.RouterModule],declarations:[d,u],providers:[r.ContextMenuService]}]}],e.ContextMenu=d,e.ContextMenuModule=m,e.ContextMenuSub=u,Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=primeng-contextmenu.umd.min.js.map