(window.cbJsonP=window.cbJsonP||[]).push([[205],{212:function(e,t,n){"use strict";var r;n.d(t,"a",(function(){return r})),function(e){e.GOOGLE_RECAPTCHA="google_recaptcha",e.TURNSTILE="turnstile",e.HCAPTCHA="hcaptcha"}(r||(r={}))},232:function(e,t,n){"use strict";n.d(t,"d",(function(){return p})),n.d(t,"e",(function(){return l})),n.d(t,"f",(function(){return d})),n.d(t,"c",(function(){return f})),n.d(t,"k",(function(){return v})),n.d(t,"i",(function(){return m})),n.d(t,"j",(function(){return y})),n.d(t,"h",(function(){return E})),n.d(t,"g",(function(){return k})),n.d(t,"b",(function(){return w})),n.d(t,"a",(function(){return x})),n.d(t,"l",(function(){return T}));var r=n(3),i=n.n(r),a=n(8),c=n.n(a),o=n(13),u=n.n(o),s=n(168),h=n(19),p=function(e,t){return l(e,(function(){return!!window[t]}))},l=function(e,t){return new u.a((function(n,r){if(1==t())n(!0);else{var i=window.setTimeout((function(){return r(h.e.scriptLoadError)}),5e4);d(e,(function e(){1==t()?(clearTimeout(i),window.setTimeout((function(){return n(!0)}),100)):window.setTimeout(e,100)}),(function(){r(h.e.scriptLoadError)}))}}))},d=function(e,t,n){var r=document.createElement("script");r.onload=t,r.onerror=n,document.head.appendChild(r),r.src=e},f=function(e){return new u.a((function(t,n){for(var r=document.styleSheets,i=0,a=r.length;ie.MAX_RETRIES){clearTimeout(c);var r=new x.a(t||e.options.errors.maxAttemptsReached);return e.triggerErrorCallback(i-1,r),n(r)}e.triggerErrorCallback(i-1,t),s()},s=(r=o()(a.a.mark((function n(){var r;return a.a.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.prev=0,clearTimeout(c),c=setTimeout((function(){return u(e.options.errors.executionTimeout)}),e.EXEC_TIMEOUT),n.next=4,e.callable();case 4:r=n.sent,i=r,clearTimeout(c),t(i),n.next=11;break;case 8:n.prev=8,n.t0=n.catch(0),u(n.t0);case 11:case"end":return n.stop()}var i}),n,e,[[0,8]])}))),function(){return r.apply(this,arguments)});s()}))),this.preparedPromise)}}]),e}(),R=function(){function e(t){s()(this,e),this.CAPTCHA_LOAD_TIMEOUT=3e4,this.CAPTCHA_GENERATE_TOKEN_TIMEOUT=1e4,this.MAX_RETRIES_GENERATE_TOKEN=3,this.MAX_RETRIES_INITIALIZE=5,this.options=t}return p()(e,[{key:"getSiteKey",value:function(){return this.options.siteKey}},{key:"initialize",value:function(){var e=this;return this.initializer||(this.initializer=new C((function(){return e.load()}),{actionName:"captcha_initialization",errors:{executionTimeout:Object(T.d)(x.e.recaptchaLoadTimeout),maxAttemptsReached:Object(T.d)(x.e.captchaInitializationMaxRetryOver)},strategy:r.ExecuteOnce,onError:this.options.onError}).setExecutionTimeout(this.CAPTCHA_LOAD_TIMEOUT).setMaxRetries(this.MAX_RETRIES_INITIALIZE)),this.initializer.execute()}},{key:"generateToken",value:function(e){var t=this;return new C(o()(a.a.mark((function n(){return a.a.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,t.initialize();case 2:return n.next=4,t.execute(e);case 4:return n.abrupt("return",n.sent);case 5:case"end":return n.stop()}}),n,t)}))),{actionName:"captcha_generate_token",errors:{executionTimeout:Object(T.d)(x.e.recaptchaInitiationTimeout),maxAttemptsReached:Object(T.d)(x.e.captchaGenerateTokenMaxRetryOver)},onError:this.options.onError}).setExecutionTimeout(this.CAPTCHA_GENERATE_TOKEN_TIMEOUT).setMaxRetries(this.MAX_RETRIES_GENERATE_TOKEN).execute()}},{key:"loadScript",value:function(){var e=this;return new f.a((function(t,n){if(e.script||!e.getSiteKey())return t();var r=document.createElement("script");r.src=e.getScriptURL(),r.async=!1,r.defer=!1,r.onload=function(){e.script=r,t()},r.onerror=function(){r.remove(),n(new x.a(Object(T.d)(x.e.recaptchaScriptLoadFailed)))},document.head.appendChild(r)}))}}]),e}(),A=function(e){function t(){return s()(this,t),E()(this,(t.__proto__||m()(t)).apply(this,arguments))}var n,r,i;return g()(t,e),p()(t,[{key:"getScriptURL",value:function(){return"https://challenges.cloudflare.com/turnstile/v0/api.js?compat=recaptcha"}},{key:"load",value:(i=o()(a.a.mark((function e(){return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.loadScript();case 2:return e.next=4,new f.a((function(e){return turnstile.ready(e)}));case 4:return this.createContainer(),e.next=7,this.render();case 7:this.widgetId=e.sent;case 8:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"handleTokenCallback",value:function(e){this.tokenResolver&&this.tokenResolver(e)}},{key:"handleErrorCallBack",value:function(e,t){Object(w.a)()&&console.error(e,t),this.tokenRejector&&this.tokenRejector(t)}},{key:"render",value:(r=o()(a.a.mark((function e(){var t=this;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new f.a((function(e,n){t.tokenRejector=n;var r=turnstile.render(t.container,{sitekey:t.getSiteKey(),execution:"execute",callback:function(e){return t.handleTokenCallback(e)},"error-callback":function(e){t.handleErrorCallBack("error",e)},"unsupported-callback":function(e){t.handleErrorCallBack("unsupported",e)},"expired-callback":function(e){t.handleErrorCallBack("expired",e)},"timeout-callback":function(e){t.handleErrorCallBack("timeout",e)}});r&&e(r)})));case 1:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"execute",value:(n=o()(a.a.mark((function e(t){var n=this;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new f.a((function(e,r){n.tokenResolver=e,n.tokenRejector=r;try{turnstile.reset(n.widgetId)}catch(e){var i={action:"cbjs_recaptcha_error",error_message:("string"==typeof e?e:e.message)||"",error_name:e.name,hp_step:"captcha_reset",captcha_config:n.options};n.options.onError&&n.options.onError(i)}turnstile.execute(n.container,{action:t})})));case 1:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"createContainer",value:function(){var e=document.createElement("div");e.id="captcha_container",e.setAttribute("class",e.id),document.body.appendChild(e),this.container=e}}]),t}(R),I=function(e){function t(){var e,n,r,i;s()(this,t);for(var a=arguments.length,c=Array(a),o=0;othis.MAX_RETRIES_INITIALIZE-1&&(e="recaptcha.net"),"https://www."+e+"/recaptcha/api.js?render="+this.getSiteKey()}}]),t}(R),O=function(e){function t(){return s()(this,t),E()(this,(t.__proto__||m()(t)).apply(this,arguments))}var n,r,i;return g()(t,e),p()(t,[{key:"load",value:(i=o()(a.a.mark((function e(){var t;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=new f.a((function(e){window.hCaptchaLoadCallback=e})),e.next=3,this.loadScript();case 3:return e.next=5,t;case 5:return this.createContainer(),e.next=8,this.render();case 8:this.widgetId=e.sent;case 9:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"execute",value:(r=o()(a.a.mark((function e(t){var n,r;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,hcaptcha.execute(this.widgetId,{async:!0});case 2:return n=e.sent,r=n.response,e.abrupt("return",r);case 5:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"getScriptURL",value:function(){return"https://js.hcaptcha.com/1/api.js?onload=hCaptchaLoadCallback&render=explicit"}},{key:"render",value:(n=o()(a.a.mark((function e(){return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",hcaptcha.render(this.container,{sitekey:this.getSiteKey()}));case 1:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"createContainer",value:function(){var e=document.createElement("div");e.id="captcha_container",e.setAttribute("class",e.id),document.body.appendChild(e),this.container=e}}]),t}(R),L=function(){var e,t;function n(e){s()(this,n),this.errors=[],this.commMgr=e}return p()(n,[{key:"initialize",value:function(e){var t=this;if(this.options=e,this.options.onError=function(e){return t.logError(e)},this.resetErrorLogs(),this.loadCaptcha)return Object(w.a)()&&console.warn("returning preloaded captcha instance",this.captcha.constructor.name),this.loadCaptcha;switch(e.provider){case l.a.TURNSTILE:this.captcha=new A(e);break;case l.a.HCAPTCHA:this.captcha=new O(e);break;case l.a.GOOGLE_RECAPTCHA:default:this.captcha=new I(e)}return this.loadCaptcha=this.commMgr.getCheckoutUtilsPlugin().then((function(e){return e.getInfo()})).then((function(){return t.captcha.initialize()})).then((function(){return{success:!0}})),this.loadCaptcha}},{key:"getErrors",value:function(){return this.errors}},{key:"logError",value:function(e){this.errors.push(e)}},{key:"resetErrorLogs",value:function(){this.errors=[]}},{key:"generateToken",value:(t=o()(a.a.mark((function e(t){var n,r;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n="string"==typeof t?t:t&&t.action,this.captcha){e.next=4;break}return Object(w.a)()&&console.warn("Captcha provider not set. Missing siteKey and provider"),e.abrupt("return");case 4:return this.resetErrorLogs(),e.next=7,this.loadCaptcha;case 7:return e.next=9,this.captcha.generateToken(n);case 9:return r=e.sent,e.abrupt("return",r);case 11:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"init",value:(e=o()(a.a.mark((function e(){return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e,this)}))),function(){return e.apply(this,arguments)})}]),n}();t.default=L}}]);
//# sourceMappingURL=205-5d80901d21a55d6ba991.js.map