[59329aa] | 1 | {"version":3,"file":"primeng-captcha.mjs","sources":["../../src/app/components/captcha/captcha.ts","../../src/app/components/captcha/primeng-captcha.ts"],"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: `<div></div>`,\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n host: {\n 'class': 'p-element'\n }\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() initCallback = \"initRecaptcha\";\n\n @Output() onResponse: EventEmitter<any> = new EventEmitter();\n\n @Output() onExpire: EventEmitter<any> = new EventEmitter();\n\n private _instance: any = null;\n\n private _language: any = null;\n\n\n @Input() get language(): string {\n return this._language;\n }\n\n set language(language: string) {\n this._language = language;\n this.init();\n }\n\n constructor(public el: ElementRef, public _zone: NgZone, public cd: ChangeDetectorRef) {}\n\n ngAfterViewInit() {\n if ((<any>window).grecaptcha) {\n if (!(<any>window).grecaptcha.render){\n setTimeout(() =>{\n this.init();\n },100)\n }\n else {\n this.init();\n }\n }\n else {\n (<any>window)[this.initCallback] = () => {\n this.init();\n }\n }\n }\n\n init() {\n this._instance = (<any>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 (<any>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 (<any>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 (<any>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","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":[],"mappings":";;;;MAYa,OAAO;IAgChB,YAAmB,EAAc,EAAS,KAAa,EAAS,EAAqB;QAAlE,OAAE,GAAF,EAAE,CAAY;QAAS,UAAK,GAAL,KAAK,CAAQ;QAAS,OAAE,GAAF,EAAE,CAAmB;QA9B5E,YAAO,GAAW,IAAI,CAAC;QAEvB,UAAK,GAAG,OAAO,CAAC;QAEhB,SAAI,GAAG,OAAO,CAAC;QAEf,SAAI,GAAG,QAAQ,CAAC;QAEhB,aAAQ,GAAG,CAAC,CAAC;QAEb,iBAAY,GAAG,eAAe,CAAC;QAE9B,eAAU,GAAsB,IAAI,YAAY,EAAE,CAAC;QAEnD,aAAQ,GAAsB,IAAI,YAAY,EAAE,CAAC;QAEnD,cAAS,GAAQ,IAAI,CAAC;QAEtB,cAAS,GAAQ,IAAI,CAAC;KAY2D;IATzF,IAAa,QAAQ;QACjB,OAAO,IAAI,CAAC,SAAS,CAAC;KACzB;IAED,IAAI,QAAQ,CAAC,QAAgB;QACzB,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAC1B,IAAI,CAAC,IAAI,EAAE,CAAC;KACf;IAID,eAAe;QACX,IAAU,MAAO,CAAC,UAAU,EAAE;YAC1B,IAAI,CAAO,MAAO,CAAC,UAAU,CAAC,MAAM,EAAC;gBACjC,UAAU,CAAC;oBACP,IAAI,CAAC,IAAI,EAAE,CAAC;iBACf,EAAC,GAAG,CAAC,CAAA;aACT;i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