{"version":3,"sources":["../../src/app/components/captcha/captcha.ts"],"names":["Captcha","el","_zone","cd","this","siteKey","theme","type","size","tabindex","language","initCallback","onResponse","EventEmitter","onExpire","_instance","prototype","ngAfterViewInit","_this","window","grecaptcha","render","init","setTimeout","nativeElement","children","sitekey","hl","callback","response","run","recaptchaCallback","expired-callback","recaptchaExpiredCallback","reset","markForCheck","getResponse","emit","ngOnDestroy","Component","args","selector","template","changeDetection","ChangeDetectionStrategy","OnPush","encapsulation","ViewEncapsulation","None","ElementRef","NgZone","ChangeDetectorRef","Input","Output","NgModule","imports","CommonModule","exports","declarations"],"mappings":"oaA+BI,SAAAA,EAAmBC,EAAuBC,EAAsBC,GAA7CC,KAAAH,GAAAA,EAAuBG,KAAAF,MAAAA,EAAsBE,KAAAD,GAAAA,EApBvDC,KAAAC,QAAkB,KAElBD,KAAAE,MAAQ,QAERF,KAAAG,KAAO,QAEPH,KAAAI,KAAO,SAEPJ,KAAAK,SAAW,EAEXL,KAAAM,SAAmB,KAEnBN,KAAAO,aAAe,gBAEdP,KAAAQ,WAAgC,IAAIC,EAAAA,aAEpCT,KAAAU,SAA8B,IAAID,EAAAA,aAEpCT,KAAAW,UAAiB,YAIzBf,EAAAgB,UAAAC,gBAAA,WAAA,IAAAC,EAAAd,KACce,OAAQC,WACHD,OAAQC,WAAWC,OAM1BjB,KAAKkB,OALLC,YAAW,WACPL,EAAKI,SACP,KAOAH,OAAQf,KAAKO,cAAgB,WACjCO,EAAKI,SAKftB,EAAAgB,UAAAM,KAAA,WAAA,IAAAJ,EAAAd,KACIA,KAAKW,UAAkBI,OAAQC,WAAWC,OAAOjB,KAAKH,GAAGuB,cAAcC,SAAS,GAAI,CAChFC,QAAWtB,KAAKC,QAChBC,MAASF,KAAKE,MACdC,KAAQH,KAAKG,KACbC,KAAQJ,KAAKI,KACbC,SAAYL,KAAKK,SACjBkB,GAAMvB,KAAKM,SACXkB,SAAY,SAACC,GAAsBX,EAAKhB,MAAM4B,KAAI,WAAM,OAAAZ,EAAKa,kBAAkBF,OAC/EG,mBAAoB,WAAOd,EAAKhB,MAAM4B,KAAI,WAAM,OAAAZ,EAAKe,kCAI7DjC,EAAAgB,UAAAkB,MAAA,WAC2B,OAAnB9B,KAAKW,YAGHI,OAAQC,WAAWc,MAAM9B,KAAKW,WACpCX,KAAKD,GAAGgC,iBAGZnC,EAAAgB,UAAAoB,YAAA,WACI,OAAuB,OAAnBhC,KAAKW,UACE,KAEEI,OAAQC,WAAWgB,YAAYhC,KAAKW,YAGrDf,EAAAgB,UAAAe,kBAAA,SAAkBF,GACdzB,KAAKQ,WAAWyB,KAAK,CACjBR,SAAUA,KAIlB7B,EAAAgB,UAAAiB,yBAAA,WACI7B,KAAKU,SAASuB,QAGlBrC,EAAAgB,UAAAsB,YAAA,WAC0B,MAAlBlC,KAAKW,WACDI,OAAQC,WAAWc,MAAM9B,KAAKW,qCAxF7CwB,EAAAA,UAASC,KAAA,CAAC,CACPC,SAAU,YACVC,SAAU,cACVC,gBAAiBC,EAAAA,wBAAwBC,OACzCC,cAAeC,EAAAA,kBAAkBC,kDAP+CC,EAAAA,kBAAxBC,EAAAA,cAA+EC,EAAAA,sDAWtIC,EAAAA,qBAEAA,EAAAA,oBAEAA,EAAAA,oBAEAA,EAAAA,wBAEAA,EAAAA,wBAEAA,EAAAA,4BAEAA,EAAAA,0BAEAC,EAAAA,yBAEAA,EAAAA,gBA0EL,iCALCC,EAAAA,SAAQd,KAAA,CAAC,CACNe,QAAS,CAACC,EAAAA,cACVC,QAAS,CAACzD,GACV0D,aAAc,CAAC1D","sourcesContent":["import {NgModule,AfterViewInit,Component,EventEmitter,Input,NgZone,OnDestroy,Output,ElementRef,ChangeDetectionStrategy, ViewEncapsulation, ChangeDetectorRef} from '@angular/core';\nimport {CommonModule} from '@angular/common';\n\n@Component({\n selector: 'p-captcha',\n template: `
`,\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None\n})\nexport class Captcha implements AfterViewInit,OnDestroy {\n\n @Input() siteKey: string = null;\n \n @Input() theme = 'light';\n \n @Input() type = 'image';\n \n @Input() size = 'normal';\n \n @Input() tabindex = 0;\n \n @Input() language: string = null;\n \n @Input() initCallback = \"initRecaptcha\";\n \n @Output() onResponse: EventEmitter = new EventEmitter();\n \n @Output() onExpire: EventEmitter = new EventEmitter();\n \n private _instance: any = null;\n\n constructor(public el: ElementRef, public _zone: NgZone, public cd: ChangeDetectorRef) {}\n \n ngAfterViewInit() {\n if ((window).grecaptcha) {\n if (!(window).grecaptcha.render){\n setTimeout(() =>{\n this.init();\n },100)\n }\n else {\n this.init();\n }\n }\n else {\n (window)[this.initCallback] = () => {\n this.init();\n }\n } \n }\n \n init() {\n this._instance = (window).grecaptcha.render(this.el.nativeElement.children[0], {\n 'sitekey': this.siteKey,\n 'theme': this.theme,\n 'type': this.type,\n 'size': this.size,\n 'tabindex': this.tabindex,\n 'hl': this.language,\n 'callback': (response: string) => {this._zone.run(() => this.recaptchaCallback(response))},\n 'expired-callback': () => {this._zone.run(() => this.recaptchaExpiredCallback())}\n });\n }\n \n reset() {\n if (this._instance === null)\n return;\n \n (window).grecaptcha.reset(this._instance);\n this.cd.markForCheck();\n }\n \n getResponse(): String {\n if (this._instance === null)\n return null;\n \n return (window).grecaptcha.getResponse(this._instance);\n }\n \n recaptchaCallback(response: string) {\n this.onResponse.emit({\n response: response\n });\n }\n\n recaptchaExpiredCallback() {\n this.onExpire.emit();\n }\n \n ngOnDestroy() {\n if (this._instance != null) {\n (window).grecaptcha.reset(this._instance);\n }\n }\n}\n\n@NgModule({\n imports: [CommonModule],\n exports: [Captcha],\n declarations: [Captcha]\n})\nexport class CaptchaModule { }\n"]}