import{cU as S,qT as w,qU as A,aQ as x,o as P,lP as L,A as k,y as j,a as u,B as U,qV as D,aS as H}from"./app.B46ok1sD.js";function h(s){if(s===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return s}function f(s,i){return f=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(a,n){return a.__proto__=n,a},f(s,i)}function T(s,i){s.prototype=Object.create(i.prototype),s.prototype.constructor=s,f(s,i)}function q(s){return Object.entries(s).filter(function(i){i[0];var a=i[1];return a||a===!1}).map(function(i){var a=i[0],n=i[1];return encodeURIComponent(a)+"="+encodeURIComponent(n)}).join("&")}function v(s){var i=s&&s.ownerDocument||document,a=i.defaultView||i.parentWindow||window;return{document:i,window:a}}function m(s){return s||document.head}var y="hcaptcha-api-script-id",C="hcaptchaOnLoad",R=[],K=function(i){i===void 0&&(i={});var a=m(i.scriptLocation);delete i.scriptLocation;var n=v(a),e=R.find(function(r){var c=r.scope;return c===n.window});if(n.document.getElementById(y)&&e)return e.promise;var t=new Promise(function(r,c){n.window[C]=r;var p=i.apihost||"https://js.hcaptcha.com";delete i.apihost;var o=n.document.createElement("script");o.id=y,o.src=p+"/1/api.js?render=explicit&onload="+C,o.async=i.loadAsync!==void 0?i.loadAsync:!0,delete i.loadAsync,o.onerror=function(l){return c("script-error")};var d=q(i);o.src+=d!==""?"&"+d:"",a.appendChild(o)});return R.push({promise:t,scope:n.window}),t},M=function(s){T(i,s);function i(n){var e;return e=s.call(this,n)||this,e._hcaptcha=void 0,e.renderCaptcha=e.renderCaptcha.bind(h(e)),e.resetCaptcha=e.resetCaptcha.bind(h(e)),e.removeCaptcha=e.removeCaptcha.bind(h(e)),e.isReady=e.isReady.bind(h(e)),e.loadCaptcha=e.loadCaptcha.bind(h(e)),e.handleOnLoad=e.handleOnLoad.bind(h(e)),e.handleSubmit=e.handleSubmit.bind(h(e)),e.handleExpire=e.handleExpire.bind(h(e)),e.handleError=e.handleError.bind(h(e)),e.handleOpen=e.handleOpen.bind(h(e)),e.handleClose=e.handleClose.bind(h(e)),e.handleChallengeExpired=e.handleChallengeExpired.bind(h(e)),e.ref=w(),e.apiScriptRequested=!1,e.state={isApiReady:!1,isRemoved:!1,elementId:n.id,captchaId:""},e}var a=i.prototype;return a.componentDidMount=function(){var e=this,t=m(this.props.scriptLocation),r=v(t);this._hcaptcha=r.window.hcaptcha||void 0;var c=typeof this._hcaptcha<"u";if(c){this.setState({isApiReady:!0},function(){e.renderCaptcha()});return}this.loadCaptcha()},a.componentWillUnmount=function(){var e=this.state.captchaId,t=this._hcaptcha;this.isReady()&&(t.reset(e),t.remove(e))},a.shouldComponentUpdate=function(e,t){return!(this.state.isApiReady!==t.isApiReady||this.state.isRemoved!==t.isRemoved)},a.componentDidUpdate=function(e){var t=this,r=["sitekey","size","theme","tabindex","languageOverride","endpoint"],c=r.every(function(p){return e[p]===t.props[p]});c||this.removeCaptcha(function(){t.renderCaptcha()})},a.loadCaptcha=function(){if(!this.apiScriptRequested){var e=this.props,t=e.apihost,r=e.assethost,c=e.endpoint,p=e.host,o=e.imghost,d=e.languageOverride,l=e.reCaptchaCompat,_=e.reportapi,b=e.sentry,g=e.custom,I=e.loadAsync,O=e.scriptLocation,E={apihost:t,assethost:r,endpoint:c,hl:d,host:p,imghost:o,recaptchacompat:l===!1?"off":null,reportapi:_,sentry:b,custom:g,loadAsync:I,scriptLocation:O};K(E).then(this.handleOnLoad).catch(this.handleError),this.apiScriptRequested=!0}},a.renderCaptcha=function(e){var t=this.state.isApiReady;if(t){var r=Object.assign({"open-callback":this.handleOpen,"close-callback":this.handleClose,"error-callback":this.handleError,"chalexpired-callback":this.handleChallengeExpired,"expired-callback":this.handleExpire,callback:this.handleSubmit},this.props,{hl:this.props.hl||this.props.languageOverride,languageOverride:void 0}),c=this._hcaptcha,p=c.render(this.ref.current,r);this.setState({isRemoved:!1,captchaId:p},function(){e&&e()})}},a.resetCaptcha=function(){var e=this.state.captchaId,t=this._hcaptcha;this.isReady()&&t.reset(e)},a.removeCaptcha=function(e){var t=this.state.captchaId,r=this._hcaptcha;this.isReady()&&this.setState({isRemoved:!0},function(){r.remove(t),e&&e()})},a.handleOnLoad=function(){var e=this;this.setState({isApiReady:!0},function(){var t=m(e.props.scriptLocation),r=v(t);e._hcaptcha=r.window.hcaptcha,e.renderCaptcha(function(){var c=e.props.onLoad;c&&c()})})},a.handleSubmit=function(e){var t=this.props.onVerify,r=this.state,c=r.isRemoved,p=r.captchaId,o=this._hcaptcha;if(!(typeof o>"u"||c)){var d=o.getResponse(p),l=o.getRespKey(p);t&&t(d,l)}},a.handleExpire=function(){var e=this.props.onExpire,t=this.state.captchaId,r=this._hcaptcha;this.isReady()&&(r.reset(t),e&&e())},a.handleError=function(e){var t=this.props.onError,r=this.state.captchaId,c=this._hcaptcha;this.isReady()&&c.reset(r),t&&t(e)},a.isReady=function(){var e=this.state,t=e.isApiReady,r=e.isRemoved;return t&&!r},a.handleOpen=function(){!this.isReady()||!this.props.onOpen||this.props.onOpen()},a.handleClose=function(){!this.isReady()||!this.props.onClose||this.props.onClose()},a.handleChallengeExpired=function(){!this.isReady()||!this.props.onChalExpired||this.props.onChalExpired()},a.execute=function(e){e===void 0&&(e=null);var t=this.state.captchaId,r=this._hcaptcha;if(this.isReady())return e&&typeof e!="object"&&(e=null),r.execute(t,e)},a.setData=function(e){var t=this.state.captchaId,r=this._hcaptcha;this.isReady()&&(e&&typeof e!="object"&&(e=null),r.setData(t,e))},a.getResponse=function(){var e=this._hcaptcha;return e.getResponse(this.state.captchaId)},a.getRespKey=function(){var e=this._hcaptcha;return e.getRespKey(this.state.captchaId)},a.render=function(){var e=this.state.elementId;return S("div",{ref:this.ref,id:e})},i}(A);function z(){const{locale:s}=x().i18n,i=P(),{shopPayParts:a}=L(),n=(typeof window>"u"?void 0:window.shopPayCaptchaSiteKey)??D,e=a.signUpCaptchaRef,t=k(null);return j(()=>{if(t.current)return e.value=t.current,()=>{e.value=void 0}},[e]),u(H,{accessibilityLabel:i("captcha.title"),children:u(U,{spacing:"small400",children:u(M,{size:"invisible",sitekey:n,languageOverride:s,ref:t})})})}const B=Object.freeze(Object.defineProperty({__proto__:null,default:z},Symbol.toStringTag,{value:"Module"}));export{M as H,B as S};