import{NgModule,Component,ElementRef,Input,EventEmitter,Renderer2,ContentChild,NgZone,ViewChild,ChangeDetectorRef,ChangeDetectionStrategy,ViewEncapsulation,ContentChildren,Output}from"@angular/core";import{trigger,style,transition,animate,useAnimation,animation}from"@angular/animations";import{CommonModule}from"@angular/common";import{DomHandler}from"primeng/dom";import{Footer,SharedModule,PrimeTemplate,PrimeNGConfig,TranslationKeys,ConfirmEventType}from"primeng/api";import{ButtonModule}from"primeng/button";import{ConfirmationService}from"primeng/api";const showAnimation=animation([style({transform:"{{transform}}",opacity:0}),animate("{{transition}}",style({transform:"none",opacity:1}))]),hideAnimation=animation([animate("{{transition}}",style({transform:"{{transform}}",opacity:0}))]);export class ConfirmDialog{constructor(t,e,i,n,o,s){this.el=t,this.renderer=e,this.confirmationService=i,this.zone=n,this.cd=o,this.config=s,this.acceptIcon="pi pi-check",this.acceptVisible=!0,this.rejectIcon="pi pi-times",this.rejectVisible=!0,this.closeOnEscape=!0,this.blockScroll=!0,this.closable=!0,this.autoZIndex=!0,this.baseZIndex=0,this.transitionOptions="150ms cubic-bezier(0, 0, 0.2, 1)",this.focusTrap=!0,this.defaultFocus="accept",this.onHide=new EventEmitter,this._position="center",this.transformOptions="scale(0.7)",this.subscription=this.confirmationService.requireConfirmation$.subscribe(t=>{t?t.key===this.key&&(this.confirmation=t,this.confirmationOptions={message:this.confirmation.message||this.message,icon:this.confirmation.icon||this.icon,header:this.confirmation.header||this.header,rejectVisible:null==this.confirmation.rejectVisible?this.rejectVisible:this.confirmation.rejectVisible,acceptVisible:null==this.confirmation.acceptVisible?this.acceptVisible:this.confirmation.acceptVisible,acceptLabel:this.confirmation.acceptLabel||this.acceptLabel,rejectLabel:this.confirmation.rejectLabel||this.rejectLabel,acceptIcon:this.confirmation.acceptIcon||this.acceptIcon,rejectIcon:this.confirmation.rejectIcon||this.rejectIcon,acceptButtonStyleClass:this.confirmation.acceptButtonStyleClass||this.acceptButtonStyleClass,rejectButtonStyleClass:this.confirmation.rejectButtonStyleClass||this.rejectButtonStyleClass,defaultFocus:this.confirmation.defaultFocus||this.defaultFocus,blockScroll:!1===this.confirmation.blockScroll||!0===this.confirmation.blockScroll?this.confirmation.blockScroll:this.blockScroll,closeOnEscape:!1===this.confirmation.closeOnEscape||!0===this.confirmation.closeOnEscape?this.confirmation.closeOnEscape:this.closeOnEscape,dismissableMask:!1===this.confirmation.dismissableMask||!0===this.confirmation.dismissableMask?this.confirmation.dismissableMask:this.dismissableMask},this.confirmation.accept&&(this.confirmation.acceptEvent=new EventEmitter,this.confirmation.acceptEvent.subscribe(this.confirmation.accept)),this.confirmation.reject&&(this.confirmation.rejectEvent=new EventEmitter,this.confirmation.rejectEvent.subscribe(this.confirmation.reject)),this.visible=!0):this.hide()})}get visible(){return this._visible}set visible(t){this._visible=t,this._visible&&!this.maskVisible&&(this.maskVisible=!0),this.cd.markForCheck()}get position(){return this._position}set position(t){switch(this._position=t,t){case"top-left":case"bottom-left":case"left":this.transformOptions="translate3d(-100%, 0px, 0px)";break;case"top-right":case"bottom-right":case"right":this.transformOptions="translate3d(100%, 0px, 0px)";break;case"bottom":this.transformOptions="translate3d(0px, 100%, 0px)";break;case"top":this.transformOptions="translate3d(0px, -100%, 0px)";break;default:this.transformOptions="scale(0.7)"}}ngAfterContentInit(){this.templates.forEach(t=>{switch(t.getType()){case"footerTemplate":this.footerTemplate=t.template}})}option(t){const e=this.confirmationOptions||this;if(e.hasOwnProperty(t))return e[t]}onAnimationStart(t){switch(t.toState){case"visible":this.container=t.element,this.wrapper=this.container.parentElement,this.contentContainer=DomHandler.findSingle(this.container,".p-dialog-content");const e=this.getElementToFocus();e&&e.focus(),this.appendContainer(),this.moveOnTop(),this.bindGlobalListeners(),this.enableModality()}}onAnimationEnd(t){switch(t.toState){case"void":this.onOverlayHide()}}getElementToFocus(){switch(this.option("defaultFocus")){case"accept":return DomHandler.findSingle(this.container,".p-confirm-dialog-accept");case"reject":return DomHandler.findSingle(this.container,".p-confirm-dialog-reject");case"close":return DomHandler.findSingle(this.container,".p-dialog-header-close");case"none":return null;default:return DomHandler.findSingle(this.container,".p-confirm-dialog-accept")}}appendContainer(){this.appendTo&&("body"===this.appendTo?document.body.appendChild(this.wrapper):DomHandler.appendChild(this.wrapper,this.appendTo))}restoreAppend(){this.wrapper&&this.appendTo&&this.el.nativeElement.appendChild(this.wrapper)}enableModality(){this.option("blockScroll")&&DomHandler.addClass(document.body,"p-overflow-hidden"),this.option("dismissableMask")&&(this.maskClickListener=this.renderer.listen(this.wrapper,"mousedown",t=>{this.wrapper&&this.wrapper.isSameNode(t.target)&&this.close(t)}))}disableModality(){this.maskVisible=!1,this.option("blockScroll")&&DomHandler.removeClass(document.body,"p-overflow-hidden"),this.dismissableMask&&this.unbindMaskClickListener(),this.container&&!this.cd.destroyed&&this.cd.detectChanges()}close(t){this.confirmation.rejectEvent&&this.confirmation.rejectEvent.emit(ConfirmEventType.CANCEL),this.hide(ConfirmEventType.CANCEL),t.preventDefault()}hide(t){this.onHide.emit(t),this.visible=!1,this.confirmation=null,this.confirmationOptions=null}moveOnTop(){this.autoZIndex&&(this.container.style.zIndex=String(this.baseZIndex+ ++DomHandler.zindex),this.wrapper.style.zIndex=String(this.baseZIndex+(DomHandler.zindex-1)))}getMaskClass(){let t={"p-dialog-mask p-component-overlay":!0,"p-dialog-mask-scrollblocker":this.blockScroll};return t[this.getPositionClass().toString()]=!0,t}getPositionClass(){const t=["left","right","top","top-left","top-right","bottom","bottom-left","bottom-right"].find(t=>t===this.position);return t?`p-dialog-${t}`:""}bindGlobalListeners(){if(this.option("closeOnEscape")&&this.closable||this.focusTrap&&!this.documentEscapeListener){const t=this.el?this.el.nativeElement.ownerDocument:"document";this.documentEscapeListener=this.renderer.listen(t,"keydown",t=>{if(27==t.which&&this.option("closeOnEscape")&&this.closable&&parseInt(this.container.style.zIndex)===DomHandler.zindex+this.baseZIndex&&this.visible&&this.close(t),9===t.which&&this.focusTrap){t.preventDefault();let e=DomHandler.getFocusableElements(this.container);if(e&&e.length>0)if(e[0].ownerDocument.activeElement){let i=e.indexOf(e[0].ownerDocument.activeElement);t.shiftKey?-1==i||0===i?e[e.length-1].focus():e[i-1].focus():-1==i||i===e.length-1?e[0].focus():e[i+1].focus()}else e[0].focus()}})}}unbindGlobalListeners(){this.documentEscapeListener&&(this.documentEscapeListener(),this.documentEscapeListener=null)}unbindMaskClickListener(){this.maskClickListener&&(this.maskClickListener(),this.maskClickListener=null)}onOverlayHide(){this.disableModality(),this.unbindGlobalListeners(),this.container=null}ngOnDestroy(){this.restoreAppend(),this.onOverlayHide(),this.subscription.unsubscribe()}accept(){this.confirmation&&this.confirmation.acceptEvent&&this.confirmation.acceptEvent.emit(),this.hide(ConfirmEventType.ACCEPT)}reject(){this.confirmation&&this.confirmation.rejectEvent&&this.confirmation.rejectEvent.emit(ConfirmEventType.REJECT),this.hide(ConfirmEventType.REJECT)}get acceptButtonLabel(){return this.option("acceptLabel")||this.config.getTranslation(TranslationKeys.ACCEPT)}get rejectButtonLabel(){return this.option("rejectLabel")||this.config.getTranslation(TranslationKeys.REJECT)}};ConfirmDialog.decorators=[{type:Component,args:[{selector:"p-confirmDialog",template:'\n