@hcaptcha/react-hcaptcha 2.0.1 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- var ae=Object.create;var I=Object.defineProperty;var oe=Object.getOwnPropertyDescriptor;var ce=Object.getOwnPropertyNames;var he=Object.getPrototypeOf,le=Object.prototype.hasOwnProperty;var ue=(t,e)=>{for(var n in e)I(t,n,{get:e[n],enumerable:!0})},F=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of ce(e))!le.call(t,s)&&s!==n&&I(t,s,{get:()=>e[s],enumerable:!(r=oe(e,s))||r.enumerable});return t};var N=(t,e,n)=>(n=t!=null?ae(he(t)):{},F(e||!t||!t.__esModule?I(n,"default",{value:t,enumerable:!0}):n,t)),de=t=>F(I({},"__esModule",{value:!0}),t);var We={};ue(We,{HCaptchaProvider:()=>D,useHCaptcha:()=>M});module.exports=de(We);var z=require("react");var W=require("react"),k=(0,W.createContext)();var M=()=>(0,z.useContext)(k);var g=N(require("react"),1);var _=N(require("react"),1);var pe=Object.defineProperty,fe=Object.defineProperties,me=Object.getOwnPropertyDescriptors,L=Object.getOwnPropertySymbols,G=Object.prototype.hasOwnProperty,X=Object.prototype.propertyIsEnumerable,T=(t,e,n)=>e in t?pe(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,m=(t,e)=>{for(var n in e||(e={}))G.call(e,n)&&T(t,n,e[n]);if(L)for(var n of L(e))X.call(e,n)&&T(t,n,e[n]);return t},Q=(t,e)=>fe(t,me(e)),ge=(t,e)=>{var n={};for(var r in t)G.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&L)for(var r of L(t))e.indexOf(r)<0&&X.call(t,r)&&(n[r]=t[r]);return n},l=(t,e,n)=>(T(t,typeof e!="symbol"?e+"":e,n),n),R=(t,e,n)=>new Promise((r,s)=>{var i=o=>{try{h(n.next(o))}catch(c){s(c)}},a=o=>{try{h(n.throw(o))}catch(c){s(c)}},h=o=>o.done?r(o.value):Promise.resolve(o.value).then(i,a);h((n=n.apply(t,e)).next())}),ye="hCaptcha-script",q="hCaptchaOnLoad",V="script-error",w="@hCaptcha/loader";function ve(t){return Object.entries(t).filter(([,e])=>e||e===!1).map(([e,n])=>`${encodeURIComponent(e)}=${encodeURIComponent(String(n))}`).join("&")}function Y(t){let e=t&&t.ownerDocument||document,n=e.defaultView||e.parentWindow||window;return{document:e,window:n}}function Z(t){return t||document.head}function xe(t){var e;t.setTag("source",w),t.setTag("url",document.URL),t.setContext("os",{UA:navigator.userAgent}),t.setContext("browser",m({},be())),t.setContext("device",Q(m({},Ee()),{screen_width_pixels:screen.width,screen_height_pixels:screen.height,language:navigator.language,orientation:((e=screen.orientation)==null?void 0:e.type)||"Unknown",processor_count:navigator.hardwareConcurrency,platform:navigator.platform}))}function be(){var t,e,n,r,s,i;let a=navigator.userAgent,h,o;return a.indexOf("Firefox")!==-1?(h="Firefox",o=(t=a.match(/Firefox\/([\d.]+)/))==null?void 0:t[1]):a.indexOf("Edg")!==-1?(h="Microsoft Edge",o=(e=a.match(/Edg\/([\d.]+)/))==null?void 0:e[1]):a.indexOf("Chrome")!==-1&&a.indexOf("Safari")!==-1?(h="Chrome",o=(n=a.match(/Chrome\/([\d.]+)/))==null?void 0:n[1]):a.indexOf("Safari")!==-1&&a.indexOf("Chrome")===-1?(h="Safari",o=(r=a.match(/Version\/([\d.]+)/))==null?void 0:r[1]):a.indexOf("Opera")!==-1||a.indexOf("OPR")!==-1?(h="Opera",o=(s=a.match(/(Opera|OPR)\/([\d.]+)/))==null?void 0:s[2]):a.indexOf("MSIE")!==-1||a.indexOf("Trident")!==-1?(h="Internet Explorer",o=(i=a.match(/(MSIE |rv:)([\d.]+)/))==null?void 0:i[2]):(h="Unknown",o="Unknown"),{name:h,version:o}}function we(t){return new Promise(e=>setTimeout(e,t))}function Ee(){let t=navigator.userAgent,e;t.indexOf("Win")!==-1?e="Windows":t.indexOf("Mac")!==-1?e="Mac":t.indexOf("Linux")!==-1?e="Linux":t.indexOf("Android")!==-1?e="Android":t.indexOf("like Mac")!==-1||t.indexOf("iPhone")!==-1||t.indexOf("iPad")!==-1?e="iOS":e="Unknown";let n;return/Mobile|iPhone|iPod|Android/i.test(t)?n="Mobile":/Tablet|iPad/i.test(t)?n="Tablet":n="Desktop",{model:e,family:e,device:n}}var Ce=class ee{constructor(e){l(this,"_parent"),l(this,"breadcrumbs",[]),l(this,"context",{}),l(this,"extra",{}),l(this,"tags",{}),l(this,"request"),l(this,"user"),this._parent=e}get parent(){return this._parent}child(){return new ee(this)}setRequest(e){return this.request=e,this}removeRequest(){return this.request=void 0,this}addBreadcrumb(e){return typeof e.timestamp>"u"&&(e.timestamp=new Date().toISOString()),this.breadcrumbs.push(e),this}setExtra(e,n){return this.extra[e]=n,this}removeExtra(e){return delete this.extra[e],this}setContext(e,n){return typeof n.type>"u"&&(n.type=e),this.context[e]=n,this}removeContext(e){return delete this.context[e],this}setTags(e){return this.tags=m(m({},this.tags),e),this}setTag(e,n){return this.tags[e]=n,this}removeTag(e){return delete this.tags[e],this}setUser(e){return this.user=e,this}removeUser(){return this.user=void 0,this}toBody(){let e=[],n=this;for(;n;)e.push(n),n=n.parent;return e.reverse().reduce((r,s)=>{var i;return r.breadcrumbs=[...(i=r.breadcrumbs)!=null?i:[],...s.breadcrumbs],r.extra=m(m({},r.extra),s.extra),r.contexts=m(m({},r.contexts),s.context),r.tags=m(m({},r.tags),s.tags),s.user&&(r.user=s.user),s.request&&(r.request=s.request),r},{breadcrumbs:[],extra:{},contexts:{},tags:{},request:void 0,user:void 0})}clear(){this.breadcrumbs=[],this.context={},this.tags={},this.user=void 0}},Re=/^\s*at (?:(.*?) ?\()?((?:file|https?|blob|chrome-extension|address|native|eval|webpack|<anonymous>|[-a-z]+:|.*bundle|\/).*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,_e=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:file|https?|blob|chrome|webpack|resource|moz-extension).*?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js))(?::(\d+))?(?::(\d+))?\s*$/i,Oe=/^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|webpack|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i,Pe=/^(?:(\w+):)\/\/(?:(\w+)(?::(\w+))?@)([\w.-]+)(?::(\d+))?\/(.+)/,j="?",J="An unknown error occurred",Se="0.0.4";function Ie(t){for(let e=0;e<t.length;e++)t[e]=Math.floor(Math.random()*256);return t}function p(t){return(t+256).toString(16).substring(1)}function ke(){let t=Ie(new Array(16));return t[6]=t[6]&15|64,t[8]=t[8]&63|128,p(t[0])+p(t[1])+p(t[2])+p(t[3])+"-"+p(t[4])+p(t[5])+"-"+p(t[6])+p(t[7])+"-"+p(t[8])+p(t[9])+"-"+p(t[10])+p(t[11])+p(t[12])+p(t[13])+p(t[14])+p(t[15])}var je=[[Re,"chrome"],[Oe,"winjs"],[_e,"gecko"]];function Ae(t){var e,n,r,s;if(!t.stack)return null;let i=[],a=(r=(n=(e=t.stack).split)==null?void 0:n.call(e,`
2
- `))!=null?r:[];for(let h=0;h<a.length;++h){let o=null,c=null,u=null;for(let[y,v]of je)if(c=y.exec(a[h]),c){u=v;break}if(!(!c||!u)){if(u==="chrome")o={filename:(s=c[2])!=null&&s.startsWith("address at ")?c[2].substring(11):c[2],function:c[1]||j,lineno:c[3]?+c[3]:null,colno:c[4]?+c[4]:null};else if(u==="winjs")o={filename:c[2],function:c[1]||j,lineno:+c[3],colno:c[4]?+c[4]:null};else if(u==="gecko")h===0&&!c[5]&&t.columnNumber!==void 0&&i.length>0&&(i[0].column=t.columnNumber+1),o={filename:c[3],function:c[1]||j,lineno:c[4]?+c[4]:null,colno:c[5]?+c[5]:null};else continue;!o.function&&o.lineno&&(o.function=j),i.push(o)}}return i.length?i.reverse():null}function qe(t){let e=Ae(t);return{type:t.name,value:t.message,stacktrace:{frames:e??[]}}}function Le(t){let e=Pe.exec(t),n=e?e.slice(1):[];if(n.length!==6)throw new Error("Invalid DSN");let r=n[5].split("/"),s=r.slice(0,-1).join("/");return n[0]+"://"+n[3]+(n[4]?":"+n[4]:"")+(s?"/"+s:"")+"/api/"+r.pop()+"/envelope/?sentry_version=7&sentry_key="+n[1]+(n[2]?"&sentry_secret="+n[2]:"")}function Me(t,e,n){var r,s;let i=m({event_id:ke().replaceAll("-",""),platform:"javascript",sdk:{name:"@hcaptcha/sentry",version:Se},environment:e,release:n,timestamp:Date.now()/1e3},t.scope.toBody());if(t.type==="exception"){i.message=(s=(r=t.error)==null?void 0:r.message)!=null?s:"Unknown error",i.fingerprint=[i.message];let a=[],h=t.error;for(let o=0;o<5&&h&&(a.push(qe(h)),!(!h.cause||!(h.cause instanceof Error)));o++)h=h.cause;i.exception={values:a.reverse()}}return t.type==="message"&&(i.message=t.message,i.level=t.level),i}function Te(t){if(t instanceof Error)return t;if(typeof t=="string")return new Error(t);if(typeof t=="object"&&t!==null&&!Array.isArray(t)){let n=t,{message:r}=n,s=ge(n,["message"]),i=new Error(typeof r=="string"?r:J);return Object.assign(i,s)}let e=new Error(J);return Object.assign(e,{cause:t})}function Ue(t,e,n){return R(this,null,function*(){var r,s;try{if(typeof fetch<"u"&&typeof AbortSignal<"u"){let i;if(n){let o=new AbortController;i=o.signal,setTimeout(()=>o.abort(),n)}let a=yield fetch(t,Q(m({},e),{signal:i})),h=yield a.text();return{status:a.status,body:h}}return yield new Promise((i,a)=>{var h,o;let c=new XMLHttpRequest;if(c.open((h=e?.method)!=null?h:"GET",t),c.onload=()=>i({status:c.status,body:c.responseText}),c.onerror=()=>a(new Error("XHR Network Error")),e?.headers)for(let[u,y]of Object.entries(e.headers))c.setRequestHeader(u,y);if(n){let u=setTimeout(()=>{c.abort(),a(new Error("Request timed out"))},n);c.onloadend=()=>{clearTimeout(u)}}c.send((o=e?.body)==null?void 0:o.toString())})}catch(i){return{status:0,body:(s=(r=i?.toString)==null?void 0:r.call(i))!=null?s:"Unknown error"}}})}var f,U=(f=class{constructor(t){l(this,"apiURL"),l(this,"dsn"),l(this,"environment"),l(this,"release"),l(this,"sampleRate"),l(this,"debug"),l(this,"_scope"),l(this,"shouldBuffer",!1),l(this,"bufferlimit",20),l(this,"buffer",[]);var e,n,r,s,i;this.environment=t.environment,this.release=t.release,this.sampleRate=(e=t.sampleRate)!=null?e:1,this.debug=(n=t.debug)!=null?n:!1,this._scope=(r=t.scope)!=null?r:new Ce,this.apiURL=Le(t.dsn),this.dsn=t.dsn,this.shouldBuffer=(s=t.buffer)!=null?s:!1,this.bufferlimit=(i=t.bufferLimit)!=null?i:20}static init(t){f._instance||(f._instance=new f(t))}static get instance(){if(!f._instance)throw new Error("Sentry has not been initialized");return f._instance}log(...t){this.debug&&console.log(...t)}get scope(){return this._scope}static get scope(){return f.instance.scope}withScope(t){let e=this._scope.child();t(e)}static withScope(t){f.instance.withScope(t)}captureException(t,e){this.captureEvent({type:"exception",level:"error",error:Te(t),scope:e??this._scope})}static captureException(t,e){f.instance.captureException(t,e)}captureMessage(t,e="info",n){this.captureEvent({type:"message",level:e,message:t,scope:n??this._scope})}static captureMessage(t,e="info",n){f.instance.captureMessage(t,e,n)}captureEvent(t){if(Math.random()>=this.sampleRate){this.log("Dropped event due to sample rate");return}if(this.shouldBuffer){if(this.buffer.length>=this.bufferlimit)return;this.buffer.push(t)}else this.sendEvent(t)}sendEvent(t,e=5e3){return R(this,null,function*(){try{this.log("Sending sentry event",t);let n=Me(t,this.environment,this.release),r={event_id:n.event_id,dsn:this.dsn},s={type:"event"},i=JSON.stringify(r)+`
1
+ var ae=Object.create;var S=Object.defineProperty;var oe=Object.getOwnPropertyDescriptor;var ce=Object.getOwnPropertyNames;var he=Object.getPrototypeOf,le=Object.prototype.hasOwnProperty;var ue=(t,e)=>{for(var n in e)S(t,n,{get:e[n],enumerable:!0})},F=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of ce(e))!le.call(t,s)&&s!==n&&S(t,s,{get:()=>e[s],enumerable:!(r=oe(e,s))||r.enumerable});return t};var N=(t,e,n)=>(n=t!=null?ae(he(t)):{},F(e||!t||!t.__esModule?S(n,"default",{value:t,enumerable:!0}):n,t)),de=t=>F(S({},"__esModule",{value:!0}),t);var We={};ue(We,{HCaptchaProvider:()=>D,useHCaptcha:()=>M});module.exports=de(We);var z=require("react");var W=require("react"),k=(0,W.createContext)();var M=()=>(0,z.useContext)(k);var g=N(require("react"),1);var _=N(require("react"),1);var pe=Object.defineProperty,fe=Object.defineProperties,me=Object.getOwnPropertyDescriptors,L=Object.getOwnPropertySymbols,G=Object.prototype.hasOwnProperty,X=Object.prototype.propertyIsEnumerable,T=(t,e,n)=>e in t?pe(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,m=(t,e)=>{for(var n in e||(e={}))G.call(e,n)&&T(t,n,e[n]);if(L)for(var n of L(e))X.call(e,n)&&T(t,n,e[n]);return t},Q=(t,e)=>fe(t,me(e)),ge=(t,e)=>{var n={};for(var r in t)G.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&L)for(var r of L(t))e.indexOf(r)<0&&X.call(t,r)&&(n[r]=t[r]);return n},l=(t,e,n)=>(T(t,typeof e!="symbol"?e+"":e,n),n),R=(t,e,n)=>new Promise((r,s)=>{var i=o=>{try{h(n.next(o))}catch(c){s(c)}},a=o=>{try{h(n.throw(o))}catch(c){s(c)}},h=o=>o.done?r(o.value):Promise.resolve(o.value).then(i,a);h((n=n.apply(t,e)).next())}),ye="hCaptcha-script",q="hCaptchaOnLoad",V="script-error",w="@hCaptcha/loader";function ve(t){return Object.entries(t).filter(([,e])=>e||e===!1).map(([e,n])=>`${encodeURIComponent(e)}=${encodeURIComponent(String(n))}`).join("&")}function Y(t){let e=t&&t.ownerDocument||document,n=e.defaultView||e.parentWindow||window;return{document:e,window:n}}function Z(t){return t||document.head}function xe(t){var e;t.setTag("source",w),t.setTag("url",document.URL),t.setContext("os",{UA:navigator.userAgent}),t.setContext("browser",m({},be())),t.setContext("device",Q(m({},Ee()),{screen_width_pixels:screen.width,screen_height_pixels:screen.height,language:navigator.language,orientation:((e=screen.orientation)==null?void 0:e.type)||"Unknown",processor_count:navigator.hardwareConcurrency,platform:navigator.platform}))}function be(){var t,e,n,r,s,i;let a=navigator.userAgent,h,o;return a.indexOf("Firefox")!==-1?(h="Firefox",o=(t=a.match(/Firefox\/([\d.]+)/))==null?void 0:t[1]):a.indexOf("Edg")!==-1?(h="Microsoft Edge",o=(e=a.match(/Edg\/([\d.]+)/))==null?void 0:e[1]):a.indexOf("Chrome")!==-1&&a.indexOf("Safari")!==-1?(h="Chrome",o=(n=a.match(/Chrome\/([\d.]+)/))==null?void 0:n[1]):a.indexOf("Safari")!==-1&&a.indexOf("Chrome")===-1?(h="Safari",o=(r=a.match(/Version\/([\d.]+)/))==null?void 0:r[1]):a.indexOf("Opera")!==-1||a.indexOf("OPR")!==-1?(h="Opera",o=(s=a.match(/(Opera|OPR)\/([\d.]+)/))==null?void 0:s[2]):a.indexOf("MSIE")!==-1||a.indexOf("Trident")!==-1?(h="Internet Explorer",o=(i=a.match(/(MSIE |rv:)([\d.]+)/))==null?void 0:i[2]):(h="Unknown",o="Unknown"),{name:h,version:o}}function we(t){return new Promise(e=>setTimeout(e,t))}function Ee(){let t=navigator.userAgent,e;t.indexOf("Win")!==-1?e="Windows":t.indexOf("Mac")!==-1?e="Mac":t.indexOf("Linux")!==-1?e="Linux":t.indexOf("Android")!==-1?e="Android":t.indexOf("like Mac")!==-1||t.indexOf("iPhone")!==-1||t.indexOf("iPad")!==-1?e="iOS":e="Unknown";let n;return/Mobile|iPhone|iPod|Android/i.test(t)?n="Mobile":/Tablet|iPad/i.test(t)?n="Tablet":n="Desktop",{model:e,family:e,device:n}}var Ce=class ee{constructor(e){l(this,"_parent"),l(this,"breadcrumbs",[]),l(this,"context",{}),l(this,"extra",{}),l(this,"tags",{}),l(this,"request"),l(this,"user"),this._parent=e}get parent(){return this._parent}child(){return new ee(this)}setRequest(e){return this.request=e,this}removeRequest(){return this.request=void 0,this}addBreadcrumb(e){return typeof e.timestamp>"u"&&(e.timestamp=new Date().toISOString()),this.breadcrumbs.push(e),this}setExtra(e,n){return this.extra[e]=n,this}removeExtra(e){return delete this.extra[e],this}setContext(e,n){return typeof n.type>"u"&&(n.type=e),this.context[e]=n,this}removeContext(e){return delete this.context[e],this}setTags(e){return this.tags=m(m({},this.tags),e),this}setTag(e,n){return this.tags[e]=n,this}removeTag(e){return delete this.tags[e],this}setUser(e){return this.user=e,this}removeUser(){return this.user=void 0,this}toBody(){let e=[],n=this;for(;n;)e.push(n),n=n.parent;return e.reverse().reduce((r,s)=>{var i;return r.breadcrumbs=[...(i=r.breadcrumbs)!=null?i:[],...s.breadcrumbs],r.extra=m(m({},r.extra),s.extra),r.contexts=m(m({},r.contexts),s.context),r.tags=m(m({},r.tags),s.tags),s.user&&(r.user=s.user),s.request&&(r.request=s.request),r},{breadcrumbs:[],extra:{},contexts:{},tags:{},request:void 0,user:void 0})}clear(){this.breadcrumbs=[],this.context={},this.tags={},this.user=void 0}},Re=/^\s*at (?:(.*?) ?\()?((?:file|https?|blob|chrome-extension|address|native|eval|webpack|<anonymous>|[-a-z]+:|.*bundle|\/).*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,_e=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:file|https?|blob|chrome|webpack|resource|moz-extension).*?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js))(?::(\d+))?(?::(\d+))?\s*$/i,Oe=/^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|webpack|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i,Pe=/^(?:(\w+):)\/\/(?:(\w+)(?::(\w+))?@)([\w.-]+)(?::(\d+))?\/(.+)/,j="?",J="An unknown error occurred",Ie="0.0.4";function Se(t){for(let e=0;e<t.length;e++)t[e]=Math.floor(Math.random()*256);return t}function p(t){return(t+256).toString(16).substring(1)}function ke(){let t=Se(new Array(16));return t[6]=t[6]&15|64,t[8]=t[8]&63|128,p(t[0])+p(t[1])+p(t[2])+p(t[3])+"-"+p(t[4])+p(t[5])+"-"+p(t[6])+p(t[7])+"-"+p(t[8])+p(t[9])+"-"+p(t[10])+p(t[11])+p(t[12])+p(t[13])+p(t[14])+p(t[15])}var je=[[Re,"chrome"],[Oe,"winjs"],[_e,"gecko"]];function Ae(t){var e,n,r,s;if(!t.stack)return null;let i=[],a=(r=(n=(e=t.stack).split)==null?void 0:n.call(e,`
2
+ `))!=null?r:[];for(let h=0;h<a.length;++h){let o=null,c=null,u=null;for(let[y,v]of je)if(c=y.exec(a[h]),c){u=v;break}if(!(!c||!u)){if(u==="chrome")o={filename:(s=c[2])!=null&&s.startsWith("address at ")?c[2].substring(11):c[2],function:c[1]||j,lineno:c[3]?+c[3]:null,colno:c[4]?+c[4]:null};else if(u==="winjs")o={filename:c[2],function:c[1]||j,lineno:+c[3],colno:c[4]?+c[4]:null};else if(u==="gecko")h===0&&!c[5]&&t.columnNumber!==void 0&&i.length>0&&(i[0].column=t.columnNumber+1),o={filename:c[3],function:c[1]||j,lineno:c[4]?+c[4]:null,colno:c[5]?+c[5]:null};else continue;!o.function&&o.lineno&&(o.function=j),i.push(o)}}return i.length?i.reverse():null}function qe(t){let e=Ae(t);return{type:t.name,value:t.message,stacktrace:{frames:e??[]}}}function Le(t){let e=Pe.exec(t),n=e?e.slice(1):[];if(n.length!==6)throw new Error("Invalid DSN");let r=n[5].split("/"),s=r.slice(0,-1).join("/");return n[0]+"://"+n[3]+(n[4]?":"+n[4]:"")+(s?"/"+s:"")+"/api/"+r.pop()+"/envelope/?sentry_version=7&sentry_key="+n[1]+(n[2]?"&sentry_secret="+n[2]:"")}function Me(t,e,n){var r,s;let i=m({event_id:ke().replaceAll("-",""),platform:"javascript",sdk:{name:"@hcaptcha/sentry",version:Ie},environment:e,release:n,timestamp:Date.now()/1e3},t.scope.toBody());if(t.type==="exception"){i.message=(s=(r=t.error)==null?void 0:r.message)!=null?s:"Unknown error",i.fingerprint=[i.message];let a=[],h=t.error;for(let o=0;o<5&&h&&(a.push(qe(h)),!(!h.cause||!(h.cause instanceof Error)));o++)h=h.cause;i.exception={values:a.reverse()}}return t.type==="message"&&(i.message=t.message,i.level=t.level),i}function Te(t){if(t instanceof Error)return t;if(typeof t=="string")return new Error(t);if(typeof t=="object"&&t!==null&&!Array.isArray(t)){let n=t,{message:r}=n,s=ge(n,["message"]),i=new Error(typeof r=="string"?r:J);return Object.assign(i,s)}let e=new Error(J);return Object.assign(e,{cause:t})}function Ue(t,e,n){return R(this,null,function*(){var r,s;try{if(typeof fetch<"u"&&typeof AbortSignal<"u"){let i;if(n){let o=new AbortController;i=o.signal,setTimeout(()=>o.abort(),n)}let a=yield fetch(t,Q(m({},e),{signal:i})),h=yield a.text();return{status:a.status,body:h}}return yield new Promise((i,a)=>{var h,o;let c=new XMLHttpRequest;if(c.open((h=e?.method)!=null?h:"GET",t),c.onload=()=>i({status:c.status,body:c.responseText}),c.onerror=()=>a(new Error("XHR Network Error")),e?.headers)for(let[u,y]of Object.entries(e.headers))c.setRequestHeader(u,y);if(n){let u=setTimeout(()=>{c.abort(),a(new Error("Request timed out"))},n);c.onloadend=()=>{clearTimeout(u)}}c.send((o=e?.body)==null?void 0:o.toString())})}catch(i){return{status:0,body:(s=(r=i?.toString)==null?void 0:r.call(i))!=null?s:"Unknown error"}}})}var f,U=(f=class{constructor(t){l(this,"apiURL"),l(this,"dsn"),l(this,"environment"),l(this,"release"),l(this,"sampleRate"),l(this,"debug"),l(this,"_scope"),l(this,"shouldBuffer",!1),l(this,"bufferlimit",20),l(this,"buffer",[]);var e,n,r,s,i;this.environment=t.environment,this.release=t.release,this.sampleRate=(e=t.sampleRate)!=null?e:1,this.debug=(n=t.debug)!=null?n:!1,this._scope=(r=t.scope)!=null?r:new Ce,this.apiURL=Le(t.dsn),this.dsn=t.dsn,this.shouldBuffer=(s=t.buffer)!=null?s:!1,this.bufferlimit=(i=t.bufferLimit)!=null?i:20}static init(t){f._instance||(f._instance=new f(t))}static get instance(){if(!f._instance)throw new Error("Sentry has not been initialized");return f._instance}log(...t){this.debug&&console.log(...t)}get scope(){return this._scope}static get scope(){return f.instance.scope}withScope(t){let e=this._scope.child();t(e)}static withScope(t){f.instance.withScope(t)}captureException(t,e){this.captureEvent({type:"exception",level:"error",error:Te(t),scope:e??this._scope})}static captureException(t,e){f.instance.captureException(t,e)}captureMessage(t,e="info",n){this.captureEvent({type:"message",level:e,message:t,scope:n??this._scope})}static captureMessage(t,e="info",n){f.instance.captureMessage(t,e,n)}captureEvent(t){if(Math.random()>=this.sampleRate){this.log("Dropped event due to sample rate");return}if(this.shouldBuffer){if(this.buffer.length>=this.bufferlimit)return;this.buffer.push(t)}else this.sendEvent(t)}sendEvent(t,e=5e3){return R(this,null,function*(){try{this.log("Sending sentry event",t);let n=Me(t,this.environment,this.release),r={event_id:n.event_id,dsn:this.dsn},s={type:"event"},i=JSON.stringify(r)+`
3
3
  `+JSON.stringify(s)+`
4
- `+JSON.stringify(n),a=yield Ue(this.apiURL,{method:"POST",headers:{"Content-Type":"application/x-sentry-envelope"},body:i},e);this.log("Sentry response",a.status),a.status!==200&&(console.log(a.body),console.error("Failed to send event to Sentry",a))}catch(n){console.error("Failed to send event",n)}})}flush(t=5e3){return R(this,null,function*(){try{this.log("Flushing sentry events",this.buffer.length);let e=this.buffer.splice(0,this.buffer.length).map(n=>this.sendEvent(n,t));yield Promise.all(e),this.log("Flushed all events")}catch(e){console.error("Failed to flush events",e)}})}static flush(t=5e3){return f.instance.flush(t)}static reset(){f._instance=void 0}},l(f,"_instance"),f),He="https://d233059272824702afc8c43834c4912d@sentry.hcaptcha.com/6",Be="2.3.0",De="production";function $e(t=!0){if(!t)return K();U.init({dsn:He,release:Be,environment:De});let e=U.scope;return xe(e),K(e)}function K(t=null){return{addBreadcrumb:e=>{t&&t.addBreadcrumb(e)},captureRequest:e=>{t&&t.setRequest(e)},captureException:e=>{t&&U.captureException(e,t)}}}function Fe({scriptLocation:t,query:e,loadAsync:n=!0,crossOrigin:r="anonymous",apihost:s="https://js.hcaptcha.com",cleanup:i=!1,secureApi:a=!1,scriptSource:h=""}={},o){let c=Z(t),u=Y(c);return new Promise((y,v)=>{let d=u.document.createElement("script");d.id=ye,h?d.src=`${h}?onload=${q}`:a?d.src=`${s}/1/secure-api.js?onload=${q}`:d.src=`${s}/1/api.js?onload=${q}`,d.crossOrigin=r,d.async=n;let E=(x,C)=>{try{!a&&i&&c.removeChild(d),C(x)}catch(S){v(S)}};d.onload=x=>E(x,y),d.onerror=x=>{o&&o(d.src),E(x,v)},d.src+=e!==""?`&${e}`:"",c.appendChild(d)})}var A=[];function Ne(t={cleanup:!1},e){try{e.addBreadcrumb({category:w,message:"hCaptcha loader params",data:t});let n=Z(t.scriptLocation),r=Y(n),s=A.find(({scope:a})=>a===r.window);if(s)return e.addBreadcrumb({category:w,message:"hCaptcha already loaded"}),s.promise;let i=new Promise((a,h)=>R(this,null,function*(){try{r.window[q]=()=>{e.addBreadcrumb({category:w,message:"hCaptcha script called onload function"}),a(r.window.hcaptcha)};let o=ve({custom:t.custom,render:t.render,sentry:t.sentry,assethost:t.assethost,imghost:t.imghost,reportapi:t.reportapi,endpoint:t.endpoint,host:t.host,recaptchacompat:t.recaptchacompat,hl:t.hl,uj:t.uj});yield Fe(m({query:o},t),c=>{e.captureRequest({url:c,method:"GET"})}),e.addBreadcrumb({category:w,message:"hCaptcha loaded",data:s})}catch{e.addBreadcrumb({category:w,message:"hCaptcha failed to load"});let c=A.findIndex(u=>u.scope===r.window);c!==-1&&A.splice(c,1),h(new Error(V))}}));return A.push({promise:i,scope:r.window}),i}catch(n){return e.captureException(n),Promise.reject(new Error(V))}}function te(t,e,n=0){return R(this,null,function*(){var r,s;let i=(r=t.maxRetries)!=null?r:2,a=(s=t.retryDelay)!=null?s:1e3,h=n<i?"Retry loading hCaptcha Api":"Exceeded maximum retries";try{return yield Ne(t,e)}catch(o){return e.addBreadcrumb({category:w,message:h}),n>=i?(e.captureException(o),Promise.reject(o)):(e.addBreadcrumb({category:w,message:`Waiting ${a}ms before retry attempt ${n+1}`}),yield we(a),n+=1,te(t,e,n))}})}function ne(){return R(this,arguments,function*(t={}){let e=$e(t.sentry);return yield te(t,e)})}function H(t){let e=t&&t.ownerDocument||document,n=e.defaultView||e.parentWindow||window;return{document:e,window:n}}function B(t){return t||document.head}var P=class extends _.Component{constructor(e){super(e),this._hcaptcha=void 0,this.renderCaptcha=this.renderCaptcha.bind(this),this.resetCaptcha=this.resetCaptcha.bind(this),this.removeCaptcha=this.removeCaptcha.bind(this),this.isReady=this.isReady.bind(this),this._onReady=null,this.loadCaptcha=this.loadCaptcha.bind(this),this.handleOnLoad=this.handleOnLoad.bind(this),this.handleSubmit=this.handleSubmit.bind(this),this.handleExpire=this.handleExpire.bind(this),this.handleError=this.handleError.bind(this),this.handleOpen=this.handleOpen.bind(this),this.handleClose=this.handleClose.bind(this),this.handleChallengeExpired=this.handleChallengeExpired.bind(this),this.ref=_.createRef(),this.apiScriptRequested=!1,this.sentryHub=null,this.captchaId="",this._pendingExecute=null,this.state={isApiReady:!1,isRemoved:!1,elementId:e.id}}componentDidMount(){let e=B(this.props.scriptLocation),n=H(e);if(this._hcaptcha=n.window.hcaptcha||void 0,typeof this._hcaptcha<"u"){this.setState({isApiReady:!0},()=>{this.renderCaptcha()});return}this.loadCaptcha()}componentWillUnmount(){let e=this._hcaptcha,n=this.captchaId;this._cancelPendingExecute("react-component-unmounted"),this.isReady()&&(e.reset(n),e.remove(n))}shouldComponentUpdate(e,n){return!(this.state.isApiReady!==n.isApiReady||this.state.isRemoved!==n.isRemoved)}componentDidUpdate(e){["sitekey","size","theme","tabindex","languageOverride","endpoint"].every(s=>e[s]===this.props[s])||this.removeCaptcha(()=>{this.renderCaptcha()})}loadCaptcha(){if(this.apiScriptRequested)return;let{apihost:e,assethost:n,endpoint:r,host:s,imghost:i,languageOverride:a,reCaptchaCompat:h,reportapi:o,sentry:c,custom:u,loadAsync:y,scriptLocation:v,scriptSource:d,secureApi:E,cleanup:x=!0,userJourneys:C}=this.props;ne({render:"explicit",apihost:e,assethost:n,endpoint:r,hl:a,host:s,imghost:i,recaptchacompat:h===!1?"off":null,reportapi:o,sentry:c,custom:u,loadAsync:y,scriptLocation:v,scriptSource:d,secureApi:E,cleanup:x,uj:C!==void 0?C:!1}).then(this.handleOnLoad,this.handleError).catch(this.handleError),this.apiScriptRequested=!0}renderCaptcha(e){let{onReady:n}=this.props,{isApiReady:r}=this.state,s=this.captchaId;if(!r||s)return;let i=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}),h=this._hcaptcha.render(this.ref.current,i);this.captchaId=h,this.setState({isRemoved:!1},()=>{e&&e(),n&&n(),this._onReady&&this._onReady(h)})}resetCaptcha(){let e=this._hcaptcha,n=this.captchaId;this.isReady()&&(e.reset(n),this._cancelPendingExecute("hcaptcha-reset"))}removeCaptcha(e){let n=this._hcaptcha,r=this.captchaId;this._cancelPendingExecute("hcaptcha-removed"),this.isReady()&&this.setState({isRemoved:!0},()=>{this.captchaId="",n.remove(r),e&&e()})}handleOnLoad(){this.setState({isApiReady:!0},()=>{let e=B(this.props.scriptLocation),n=H(e);this._hcaptcha=n.window.hcaptcha,this.renderCaptcha(()=>{let{onLoad:r}=this.props;r&&r()})})}handleSubmit(e){let{onVerify:n}=this.props,{isRemoved:r}=this.state,s=this._hcaptcha,i=this.captchaId;if(typeof s>"u"||r)return;let a=s.getResponse(i),h=s.getRespKey(i);n&&n(a,h)}handleExpire(){let{onExpire:e}=this.props,n=this._hcaptcha,r=this.captchaId;this.isReady()&&(n.reset(r),e&&e())}handleError(e){let{onError:n}=this.props,r=this._hcaptcha,s=this.captchaId;this.isReady()&&r.reset(s),n&&n(e)}isReady(){let{isApiReady:e,isRemoved:n}=this.state;return e&&!n}_cancelPendingExecute(e){if(!this._pendingExecute)return;let n=this._pendingExecute;this._pendingExecute=null;let r=new Error(e);n.reject(r)}handleOpen(){!this.isReady()||!this.props.onOpen||this.props.onOpen()}handleClose(){!this.isReady()||!this.props.onClose||this.props.onClose()}handleChallengeExpired(){!this.isReady()||!this.props.onChalExpired||this.props.onChalExpired()}execute(e=null){e=typeof e=="object"?e:null;try{let n=this._hcaptcha,r=this.captchaId;if(e&&e.async&&this._pendingExecute&&this._cancelPendingExecute("hcaptcha-execute-replaced"),!this.isReady())return e&&e.async?new Promise((i,a)=>{this._pendingExecute={resolve:i,reject:a},this._onReady=h=>{if(this._pendingExecute)try{let o=n.execute(h,e);o&&typeof o.then=="function"?o.then(c=>{this._pendingExecute=null,i(c)}).catch(c=>{this._pendingExecute=null,a(c)}):(this._pendingExecute=null,a(new Error("hcaptcha-execute-no-promise")))}catch(o){this._pendingExecute=null,a(o)}}}):(this._onReady=i=>{n.execute(i,e)},null);let s=n.execute(r,e);return e&&e.async&&s&&typeof s.then=="function"?new Promise((i,a)=>{this._pendingExecute={resolve:i,reject:a},s.then(h=>{this._pendingExecute=null,i(h)}).catch(h=>{this._pendingExecute=null,a(h)})}):s}catch(n){return e&&e.async?Promise.reject(n):null}}close(){let e=this._hcaptcha,n=this.captchaId;if(this._cancelPendingExecute("hcaptcha-closed"),!!this.isReady())return e.close(n)}setData(e){let n=this._hcaptcha,r=this.captchaId;this.isReady()&&(e&&typeof e!="object"&&(e=null),n.setData(r,e))}getResponse(){return this._hcaptcha.getResponse(this.captchaId)}getRespKey(){return this._hcaptcha.getRespKey(this.captchaId)}render(){let{elementId:e}=this.state;return _.createElement("div",{ref:this.ref,id:e})}};var re=P;function D({sitekey:t=null,size:e="normal",theme:n="light",rqdata:r=null,languageOverride:s=null,onVerify:i,onError:a,children:h}){let o=(0,g.useRef)(null),[c,u]=(0,g.useState)(!1),[y,v]=(0,g.useState)(null),[d,E]=(0,g.useState)(null),x=()=>{u(!0)},C=b=>{E(b),a&&a(b)},S=()=>{v(null)},se=b=>{v(b),i&&i(b)},ie=async(b={})=>{try{if(!c)throw new Error("hCaptcha not ready");y&&$();let{response:O}=await o.current.execute({async:!0,...b.rqdata?{rqdata:b.rqdata}:{}});return v(O),O}catch(O){E(O),a&&a(O)}},$=()=>{o?.current?.resetCaptcha()};return(0,g.useEffect)(()=>{r&&o?.current?.setData(r)},[r]),g.default.createElement(k.Provider,{value:{sitekey:t,error:d,token:y,ready:c,executeInstance:ie,resetInstance:$}},h,g.default.createElement(re,{sitekey:t,size:e,theme:n,languageOverride:s,onReady:x,onVerify:se,onExpire:S,onError:C,ref:o}))}
4
+ `+JSON.stringify(n),a=yield Ue(this.apiURL,{method:"POST",headers:{"Content-Type":"application/x-sentry-envelope"},body:i},e);this.log("Sentry response",a.status),a.status!==200&&(console.log(a.body),console.error("Failed to send event to Sentry",a))}catch(n){console.error("Failed to send event",n)}})}flush(t=5e3){return R(this,null,function*(){try{this.log("Flushing sentry events",this.buffer.length);let e=this.buffer.splice(0,this.buffer.length).map(n=>this.sendEvent(n,t));yield Promise.all(e),this.log("Flushed all events")}catch(e){console.error("Failed to flush events",e)}})}static flush(t=5e3){return f.instance.flush(t)}static reset(){f._instance=void 0}},l(f,"_instance"),f),He="https://d233059272824702afc8c43834c4912d@sentry.hcaptcha.com/6",Be="2.3.0",De="production";function $e(t=!0){if(!t)return K();U.init({dsn:He,release:Be,environment:De});let e=U.scope;return xe(e),K(e)}function K(t=null){return{addBreadcrumb:e=>{t&&t.addBreadcrumb(e)},captureRequest:e=>{t&&t.setRequest(e)},captureException:e=>{t&&U.captureException(e,t)}}}function Fe({scriptLocation:t,query:e,loadAsync:n=!0,crossOrigin:r="anonymous",apihost:s="https://js.hcaptcha.com",cleanup:i=!1,secureApi:a=!1,scriptSource:h=""}={},o){let c=Z(t),u=Y(c);return new Promise((y,v)=>{let d=u.document.createElement("script");d.id=ye,h?d.src=`${h}?onload=${q}`:a?d.src=`${s}/1/secure-api.js?onload=${q}`:d.src=`${s}/1/api.js?onload=${q}`,d.crossOrigin=r,d.async=n;let E=(x,C)=>{try{!a&&i&&c.removeChild(d),C(x)}catch(I){v(I)}};d.onload=x=>E(x,y),d.onerror=x=>{o&&o(d.src),E(x,v)},d.src+=e!==""?`&${e}`:"",c.appendChild(d)})}var A=[];function Ne(t={cleanup:!1},e){try{e.addBreadcrumb({category:w,message:"hCaptcha loader params",data:t});let n=Z(t.scriptLocation),r=Y(n),s=A.find(({scope:a})=>a===r.window);if(s)return e.addBreadcrumb({category:w,message:"hCaptcha already loaded"}),s.promise;let i=new Promise((a,h)=>R(this,null,function*(){try{r.window[q]=()=>{e.addBreadcrumb({category:w,message:"hCaptcha script called onload function"}),a(r.window.hcaptcha)};let o=ve({custom:t.custom,render:t.render,sentry:t.sentry,assethost:t.assethost,imghost:t.imghost,reportapi:t.reportapi,endpoint:t.endpoint,host:t.host,recaptchacompat:t.recaptchacompat,hl:t.hl,uj:t.uj});yield Fe(m({query:o},t),c=>{e.captureRequest({url:c,method:"GET"})}),e.addBreadcrumb({category:w,message:"hCaptcha loaded",data:s})}catch{e.addBreadcrumb({category:w,message:"hCaptcha failed to load"});let c=A.findIndex(u=>u.scope===r.window);c!==-1&&A.splice(c,1),h(new Error(V))}}));return A.push({promise:i,scope:r.window}),i}catch(n){return e.captureException(n),Promise.reject(new Error(V))}}function te(t,e,n=0){return R(this,null,function*(){var r,s;let i=(r=t.maxRetries)!=null?r:2,a=(s=t.retryDelay)!=null?s:1e3,h=n<i?"Retry loading hCaptcha Api":"Exceeded maximum retries";try{return yield Ne(t,e)}catch(o){return e.addBreadcrumb({category:w,message:h}),n>=i?(e.captureException(o),Promise.reject(o)):(e.addBreadcrumb({category:w,message:`Waiting ${a}ms before retry attempt ${n+1}`}),yield we(a),n+=1,te(t,e,n))}})}function ne(){return R(this,arguments,function*(t={}){let e=$e(t.sentry);return yield te(t,e)})}function H(t){let e=t&&t.ownerDocument||document,n=e.defaultView||e.parentWindow||window;return{document:e,window:n}}function B(t){return t||document.head}var P=class extends _.Component{constructor(e){super(e),this._hcaptcha=void 0,this.renderCaptcha=this.renderCaptcha.bind(this),this.resetCaptcha=this.resetCaptcha.bind(this),this.removeCaptcha=this.removeCaptcha.bind(this),this.isReady=this.isReady.bind(this),this._onReady=null,this.loadCaptcha=this.loadCaptcha.bind(this),this.handleOnLoad=this.handleOnLoad.bind(this),this.handleSubmit=this.handleSubmit.bind(this),this.handleExpire=this.handleExpire.bind(this),this.handleError=this.handleError.bind(this),this.handleOpen=this.handleOpen.bind(this),this.handleClose=this.handleClose.bind(this),this.handleChallengeExpired=this.handleChallengeExpired.bind(this),this.ref=_.createRef(),this.apiScriptRequested=!1,this.sentryHub=null,this.captchaId="",this._pendingExecute=null,this.state={isApiReady:!1,isRemoved:!1,elementId:e.id}}componentDidMount(){let e=B(this.props.scriptLocation),n=H(e);if(this._hcaptcha=n.window.hcaptcha||void 0,typeof this._hcaptcha<"u"){this.setState({isApiReady:!0},()=>{this.renderCaptcha()});return}this.loadCaptcha()}componentWillUnmount(){let e=this._hcaptcha,n=this.captchaId;if(this._cancelPendingExecute("react-component-unmounted"),!!this.isReady())try{e.reset(n),e.remove(n)}catch{}finally{this.captchaId="",this._onReady=null}}shouldComponentUpdate(e,n){return!(this.state.isApiReady!==n.isApiReady||this.state.isRemoved!==n.isRemoved)}componentDidUpdate(e){["sitekey","size","theme","tabindex","languageOverride","endpoint"].every(s=>e[s]===this.props[s])||this.removeCaptcha(()=>{this.renderCaptcha()})}loadCaptcha(){if(this.apiScriptRequested)return;let{apihost:e,assethost:n,endpoint:r,host:s,imghost:i,languageOverride:a,reCaptchaCompat:h,reportapi:o,sentry:c,custom:u,loadAsync:y,scriptLocation:v,scriptSource:d,secureApi:E,cleanup:x=!0,userJourneys:C}=this.props;ne({render:"explicit",apihost:e,assethost:n,endpoint:r,hl:a,host:s,imghost:i,recaptchacompat:h===!1?"off":null,reportapi:o,sentry:c,custom:u,loadAsync:y,scriptLocation:v,scriptSource:d,secureApi:E,cleanup:x,uj:C!==void 0?C:!1}).then(this.handleOnLoad,this.handleError).catch(this.handleError),this.apiScriptRequested=!0}renderCaptcha(e){let{onReady:n}=this.props,{isApiReady:r}=this.state,s=this.captchaId;if(!r||s)return;let i=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}),h=this._hcaptcha.render(this.ref.current,i);this.captchaId=h,this.setState({isRemoved:!1},()=>{e&&e(),n&&n(),this._onReady&&this._onReady(h)})}resetCaptcha(){let e=this._hcaptcha,n=this.captchaId;this.isReady()&&(e.reset(n),this._cancelPendingExecute("hcaptcha-reset"))}removeCaptcha(e){let n=this._hcaptcha,r=this.captchaId;this._cancelPendingExecute("hcaptcha-removed"),this.isReady()&&this.setState({isRemoved:!0},()=>{this.captchaId="",n.remove(r),e&&e()})}handleOnLoad(){this.setState({isApiReady:!0},()=>{let e=B(this.props.scriptLocation),n=H(e);this._hcaptcha=n.window.hcaptcha,this.renderCaptcha(()=>{let{onLoad:r}=this.props;r&&r()})})}handleSubmit(e){let{onVerify:n}=this.props,{isRemoved:r}=this.state,s=this._hcaptcha,i=this.captchaId;if(typeof s>"u"||r)return;let a=s.getResponse(i),h=s.getRespKey(i);n&&n(a,h)}handleExpire(){let{onExpire:e}=this.props,n=this._hcaptcha,r=this.captchaId;this.isReady()&&(n.reset(r),e&&e())}handleError(e){let{onError:n}=this.props,r=this._hcaptcha,s=this.captchaId;this.isReady()&&r.reset(s),n&&n(e)}isReady(){let{isApiReady:e,isRemoved:n}=this.state;return e&&!n}_cancelPendingExecute(e){if(!this._pendingExecute)return;let n=this._pendingExecute;this._pendingExecute=null;let r=new Error(e);n.reject(r)}handleOpen(){!this.isReady()||!this.props.onOpen||this.props.onOpen()}handleClose(){!this.isReady()||!this.props.onClose||this.props.onClose()}handleChallengeExpired(){!this.isReady()||!this.props.onChalExpired||this.props.onChalExpired()}execute(e=null){e=typeof e=="object"?e:null;try{let n=this._hcaptcha,r=this.captchaId;if(e&&e.async&&this._pendingExecute&&this._cancelPendingExecute("hcaptcha-execute-replaced"),!this.isReady())return e&&e.async?new Promise((i,a)=>{this._pendingExecute={resolve:i,reject:a},this._onReady=h=>{if(this._pendingExecute)try{let o=n.execute(h,e);o&&typeof o.then=="function"?o.then(c=>{this._pendingExecute=null,i(c)}).catch(c=>{this._pendingExecute=null,a(c)}):(this._pendingExecute=null,a(new Error("hcaptcha-execute-no-promise")))}catch(o){this._pendingExecute=null,a(o)}}}):(this._onReady=i=>{n.execute(i,e)},null);let s=n.execute(r,e);return e&&e.async&&s&&typeof s.then=="function"?new Promise((i,a)=>{this._pendingExecute={resolve:i,reject:a},s.then(h=>{this._pendingExecute=null,i(h)}).catch(h=>{this._pendingExecute=null,a(h)})}):s}catch(n){return e&&e.async?Promise.reject(n):null}}close(){let e=this._hcaptcha,n=this.captchaId;if(this._cancelPendingExecute("hcaptcha-closed"),!!this.isReady())return e.close(n)}setData(e){let n=this._hcaptcha,r=this.captchaId;this.isReady()&&(e&&typeof e!="object"&&(e=null),n.setData(r,e))}getResponse(){return this._hcaptcha.getResponse(this.captchaId)}getRespKey(){return this._hcaptcha.getRespKey(this.captchaId)}render(){let{elementId:e}=this.state;return _.createElement("div",{ref:this.ref,id:e})}};var re=P;function D({sitekey:t=null,size:e="normal",theme:n="light",rqdata:r=null,languageOverride:s=null,onVerify:i,onError:a,children:h}){let o=(0,g.useRef)(null),[c,u]=(0,g.useState)(!1),[y,v]=(0,g.useState)(null),[d,E]=(0,g.useState)(null),x=()=>{u(!0)},C=b=>{E(b),a&&a(b)},I=()=>{v(null)},se=b=>{v(b),i&&i(b)},ie=async(b={})=>{try{if(!c)throw new Error("hCaptcha not ready");y&&$();let{response:O}=await o.current.execute({async:!0,...b.rqdata?{rqdata:b.rqdata}:{}});return v(O),O}catch(O){E(O),a&&a(O)}},$=()=>{o?.current?.resetCaptcha()};return(0,g.useEffect)(()=>{r&&o?.current?.setData(r)},[r]),g.default.createElement(k.Provider,{value:{sitekey:t,error:d,token:y,ready:c,executeInstance:ie,resetInstance:$}},h,g.default.createElement(re,{sitekey:t,size:e,theme:n,languageOverride:s,onReady:x,onVerify:se,onExpire:I,onError:C,ref:o}))}
@@ -1,4 +1,4 @@
1
- var ae=Object.create;var I=Object.defineProperty;var oe=Object.getOwnPropertyDescriptor;var ce=Object.getOwnPropertyNames;var he=Object.getPrototypeOf,le=Object.prototype.hasOwnProperty;var ue=(t,e)=>{for(var n in e)I(t,n,{get:e[n],enumerable:!0})},N=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of ce(e))!le.call(t,s)&&s!==n&&I(t,s,{get:()=>e[s],enumerable:!(r=oe(e,s))||r.enumerable});return t};var W=(t,e,n)=>(n=t!=null?ae(he(t)):{},N(e||!t||!t.__esModule?I(n,"default",{value:t,enumerable:!0}):n,t)),de=t=>N(I({},"__esModule",{value:!0}),t);var We={};ue(We,{HCaptcha:()=>_,HCaptchaProvider:()=>D,default:()=>$,useHCaptcha:()=>B});module.exports=de(We);var O=W(require("react"),1);var pe=Object.defineProperty,fe=Object.defineProperties,me=Object.getOwnPropertyDescriptors,q=Object.getOwnPropertySymbols,K=Object.prototype.hasOwnProperty,G=Object.prototype.propertyIsEnumerable,M=(t,e,n)=>e in t?pe(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,m=(t,e)=>{for(var n in e||(e={}))K.call(e,n)&&M(t,n,e[n]);if(q)for(var n of q(e))G.call(e,n)&&M(t,n,e[n]);return t},X=(t,e)=>fe(t,me(e)),ge=(t,e)=>{var n={};for(var r in t)K.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&q)for(var r of q(t))e.indexOf(r)<0&&G.call(t,r)&&(n[r]=t[r]);return n},l=(t,e,n)=>(M(t,typeof e!="symbol"?e+"":e,n),n),R=(t,e,n)=>new Promise((r,s)=>{var i=o=>{try{h(n.next(o))}catch(c){s(c)}},a=o=>{try{h(n.throw(o))}catch(c){s(c)}},h=o=>o.done?r(o.value):Promise.resolve(o.value).then(i,a);h((n=n.apply(t,e)).next())}),ye="hCaptcha-script",A="hCaptchaOnLoad",z="script-error",w="@hCaptcha/loader";function ve(t){return Object.entries(t).filter(([,e])=>e||e===!1).map(([e,n])=>`${encodeURIComponent(e)}=${encodeURIComponent(String(n))}`).join("&")}function Q(t){let e=t&&t.ownerDocument||document,n=e.defaultView||e.parentWindow||window;return{document:e,window:n}}function Y(t){return t||document.head}function xe(t){var e;t.setTag("source",w),t.setTag("url",document.URL),t.setContext("os",{UA:navigator.userAgent}),t.setContext("browser",m({},be())),t.setContext("device",X(m({},Ee()),{screen_width_pixels:screen.width,screen_height_pixels:screen.height,language:navigator.language,orientation:((e=screen.orientation)==null?void 0:e.type)||"Unknown",processor_count:navigator.hardwareConcurrency,platform:navigator.platform}))}function be(){var t,e,n,r,s,i;let a=navigator.userAgent,h,o;return a.indexOf("Firefox")!==-1?(h="Firefox",o=(t=a.match(/Firefox\/([\d.]+)/))==null?void 0:t[1]):a.indexOf("Edg")!==-1?(h="Microsoft Edge",o=(e=a.match(/Edg\/([\d.]+)/))==null?void 0:e[1]):a.indexOf("Chrome")!==-1&&a.indexOf("Safari")!==-1?(h="Chrome",o=(n=a.match(/Chrome\/([\d.]+)/))==null?void 0:n[1]):a.indexOf("Safari")!==-1&&a.indexOf("Chrome")===-1?(h="Safari",o=(r=a.match(/Version\/([\d.]+)/))==null?void 0:r[1]):a.indexOf("Opera")!==-1||a.indexOf("OPR")!==-1?(h="Opera",o=(s=a.match(/(Opera|OPR)\/([\d.]+)/))==null?void 0:s[2]):a.indexOf("MSIE")!==-1||a.indexOf("Trident")!==-1?(h="Internet Explorer",o=(i=a.match(/(MSIE |rv:)([\d.]+)/))==null?void 0:i[2]):(h="Unknown",o="Unknown"),{name:h,version:o}}function we(t){return new Promise(e=>setTimeout(e,t))}function Ee(){let t=navigator.userAgent,e;t.indexOf("Win")!==-1?e="Windows":t.indexOf("Mac")!==-1?e="Mac":t.indexOf("Linux")!==-1?e="Linux":t.indexOf("Android")!==-1?e="Android":t.indexOf("like Mac")!==-1||t.indexOf("iPhone")!==-1||t.indexOf("iPad")!==-1?e="iOS":e="Unknown";let n;return/Mobile|iPhone|iPod|Android/i.test(t)?n="Mobile":/Tablet|iPad/i.test(t)?n="Tablet":n="Desktop",{model:e,family:e,device:n}}var Ce=class Z{constructor(e){l(this,"_parent"),l(this,"breadcrumbs",[]),l(this,"context",{}),l(this,"extra",{}),l(this,"tags",{}),l(this,"request"),l(this,"user"),this._parent=e}get parent(){return this._parent}child(){return new Z(this)}setRequest(e){return this.request=e,this}removeRequest(){return this.request=void 0,this}addBreadcrumb(e){return typeof e.timestamp>"u"&&(e.timestamp=new Date().toISOString()),this.breadcrumbs.push(e),this}setExtra(e,n){return this.extra[e]=n,this}removeExtra(e){return delete this.extra[e],this}setContext(e,n){return typeof n.type>"u"&&(n.type=e),this.context[e]=n,this}removeContext(e){return delete this.context[e],this}setTags(e){return this.tags=m(m({},this.tags),e),this}setTag(e,n){return this.tags[e]=n,this}removeTag(e){return delete this.tags[e],this}setUser(e){return this.user=e,this}removeUser(){return this.user=void 0,this}toBody(){let e=[],n=this;for(;n;)e.push(n),n=n.parent;return e.reverse().reduce((r,s)=>{var i;return r.breadcrumbs=[...(i=r.breadcrumbs)!=null?i:[],...s.breadcrumbs],r.extra=m(m({},r.extra),s.extra),r.contexts=m(m({},r.contexts),s.context),r.tags=m(m({},r.tags),s.tags),s.user&&(r.user=s.user),s.request&&(r.request=s.request),r},{breadcrumbs:[],extra:{},contexts:{},tags:{},request:void 0,user:void 0})}clear(){this.breadcrumbs=[],this.context={},this.tags={},this.user=void 0}},Re=/^\s*at (?:(.*?) ?\()?((?:file|https?|blob|chrome-extension|address|native|eval|webpack|<anonymous>|[-a-z]+:|.*bundle|\/).*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,_e=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:file|https?|blob|chrome|webpack|resource|moz-extension).*?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js))(?::(\d+))?(?::(\d+))?\s*$/i,Oe=/^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|webpack|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i,Pe=/^(?:(\w+):)\/\/(?:(\w+)(?::(\w+))?@)([\w.-]+)(?::(\d+))?\/(.+)/,k="?",V="An unknown error occurred",Se="0.0.4";function Ie(t){for(let e=0;e<t.length;e++)t[e]=Math.floor(Math.random()*256);return t}function p(t){return(t+256).toString(16).substring(1)}function ke(){let t=Ie(new Array(16));return t[6]=t[6]&15|64,t[8]=t[8]&63|128,p(t[0])+p(t[1])+p(t[2])+p(t[3])+"-"+p(t[4])+p(t[5])+"-"+p(t[6])+p(t[7])+"-"+p(t[8])+p(t[9])+"-"+p(t[10])+p(t[11])+p(t[12])+p(t[13])+p(t[14])+p(t[15])}var je=[[Re,"chrome"],[Oe,"winjs"],[_e,"gecko"]];function Ae(t){var e,n,r,s;if(!t.stack)return null;let i=[],a=(r=(n=(e=t.stack).split)==null?void 0:n.call(e,`
2
- `))!=null?r:[];for(let h=0;h<a.length;++h){let o=null,c=null,u=null;for(let[y,v]of je)if(c=y.exec(a[h]),c){u=v;break}if(!(!c||!u)){if(u==="chrome")o={filename:(s=c[2])!=null&&s.startsWith("address at ")?c[2].substring(11):c[2],function:c[1]||k,lineno:c[3]?+c[3]:null,colno:c[4]?+c[4]:null};else if(u==="winjs")o={filename:c[2],function:c[1]||k,lineno:+c[3],colno:c[4]?+c[4]:null};else if(u==="gecko")h===0&&!c[5]&&t.columnNumber!==void 0&&i.length>0&&(i[0].column=t.columnNumber+1),o={filename:c[3],function:c[1]||k,lineno:c[4]?+c[4]:null,colno:c[5]?+c[5]:null};else continue;!o.function&&o.lineno&&(o.function=k),i.push(o)}}return i.length?i.reverse():null}function qe(t){let e=Ae(t);return{type:t.name,value:t.message,stacktrace:{frames:e??[]}}}function Le(t){let e=Pe.exec(t),n=e?e.slice(1):[];if(n.length!==6)throw new Error("Invalid DSN");let r=n[5].split("/"),s=r.slice(0,-1).join("/");return n[0]+"://"+n[3]+(n[4]?":"+n[4]:"")+(s?"/"+s:"")+"/api/"+r.pop()+"/envelope/?sentry_version=7&sentry_key="+n[1]+(n[2]?"&sentry_secret="+n[2]:"")}function Me(t,e,n){var r,s;let i=m({event_id:ke().replaceAll("-",""),platform:"javascript",sdk:{name:"@hcaptcha/sentry",version:Se},environment:e,release:n,timestamp:Date.now()/1e3},t.scope.toBody());if(t.type==="exception"){i.message=(s=(r=t.error)==null?void 0:r.message)!=null?s:"Unknown error",i.fingerprint=[i.message];let a=[],h=t.error;for(let o=0;o<5&&h&&(a.push(qe(h)),!(!h.cause||!(h.cause instanceof Error)));o++)h=h.cause;i.exception={values:a.reverse()}}return t.type==="message"&&(i.message=t.message,i.level=t.level),i}function Te(t){if(t instanceof Error)return t;if(typeof t=="string")return new Error(t);if(typeof t=="object"&&t!==null&&!Array.isArray(t)){let n=t,{message:r}=n,s=ge(n,["message"]),i=new Error(typeof r=="string"?r:V);return Object.assign(i,s)}let e=new Error(V);return Object.assign(e,{cause:t})}function Ue(t,e,n){return R(this,null,function*(){var r,s;try{if(typeof fetch<"u"&&typeof AbortSignal<"u"){let i;if(n){let o=new AbortController;i=o.signal,setTimeout(()=>o.abort(),n)}let a=yield fetch(t,X(m({},e),{signal:i})),h=yield a.text();return{status:a.status,body:h}}return yield new Promise((i,a)=>{var h,o;let c=new XMLHttpRequest;if(c.open((h=e?.method)!=null?h:"GET",t),c.onload=()=>i({status:c.status,body:c.responseText}),c.onerror=()=>a(new Error("XHR Network Error")),e?.headers)for(let[u,y]of Object.entries(e.headers))c.setRequestHeader(u,y);if(n){let u=setTimeout(()=>{c.abort(),a(new Error("Request timed out"))},n);c.onloadend=()=>{clearTimeout(u)}}c.send((o=e?.body)==null?void 0:o.toString())})}catch(i){return{status:0,body:(s=(r=i?.toString)==null?void 0:r.call(i))!=null?s:"Unknown error"}}})}var f,T=(f=class{constructor(t){l(this,"apiURL"),l(this,"dsn"),l(this,"environment"),l(this,"release"),l(this,"sampleRate"),l(this,"debug"),l(this,"_scope"),l(this,"shouldBuffer",!1),l(this,"bufferlimit",20),l(this,"buffer",[]);var e,n,r,s,i;this.environment=t.environment,this.release=t.release,this.sampleRate=(e=t.sampleRate)!=null?e:1,this.debug=(n=t.debug)!=null?n:!1,this._scope=(r=t.scope)!=null?r:new Ce,this.apiURL=Le(t.dsn),this.dsn=t.dsn,this.shouldBuffer=(s=t.buffer)!=null?s:!1,this.bufferlimit=(i=t.bufferLimit)!=null?i:20}static init(t){f._instance||(f._instance=new f(t))}static get instance(){if(!f._instance)throw new Error("Sentry has not been initialized");return f._instance}log(...t){this.debug&&console.log(...t)}get scope(){return this._scope}static get scope(){return f.instance.scope}withScope(t){let e=this._scope.child();t(e)}static withScope(t){f.instance.withScope(t)}captureException(t,e){this.captureEvent({type:"exception",level:"error",error:Te(t),scope:e??this._scope})}static captureException(t,e){f.instance.captureException(t,e)}captureMessage(t,e="info",n){this.captureEvent({type:"message",level:e,message:t,scope:n??this._scope})}static captureMessage(t,e="info",n){f.instance.captureMessage(t,e,n)}captureEvent(t){if(Math.random()>=this.sampleRate){this.log("Dropped event due to sample rate");return}if(this.shouldBuffer){if(this.buffer.length>=this.bufferlimit)return;this.buffer.push(t)}else this.sendEvent(t)}sendEvent(t,e=5e3){return R(this,null,function*(){try{this.log("Sending sentry event",t);let n=Me(t,this.environment,this.release),r={event_id:n.event_id,dsn:this.dsn},s={type:"event"},i=JSON.stringify(r)+`
1
+ var ae=Object.create;var S=Object.defineProperty;var oe=Object.getOwnPropertyDescriptor;var ce=Object.getOwnPropertyNames;var he=Object.getPrototypeOf,le=Object.prototype.hasOwnProperty;var ue=(t,e)=>{for(var n in e)S(t,n,{get:e[n],enumerable:!0})},N=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of ce(e))!le.call(t,s)&&s!==n&&S(t,s,{get:()=>e[s],enumerable:!(r=oe(e,s))||r.enumerable});return t};var W=(t,e,n)=>(n=t!=null?ae(he(t)):{},N(e||!t||!t.__esModule?S(n,"default",{value:t,enumerable:!0}):n,t)),de=t=>N(S({},"__esModule",{value:!0}),t);var We={};ue(We,{HCaptcha:()=>_,HCaptchaProvider:()=>D,default:()=>$,useHCaptcha:()=>B});module.exports=de(We);var O=W(require("react"),1);var pe=Object.defineProperty,fe=Object.defineProperties,me=Object.getOwnPropertyDescriptors,q=Object.getOwnPropertySymbols,K=Object.prototype.hasOwnProperty,G=Object.prototype.propertyIsEnumerable,M=(t,e,n)=>e in t?pe(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,m=(t,e)=>{for(var n in e||(e={}))K.call(e,n)&&M(t,n,e[n]);if(q)for(var n of q(e))G.call(e,n)&&M(t,n,e[n]);return t},X=(t,e)=>fe(t,me(e)),ge=(t,e)=>{var n={};for(var r in t)K.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&q)for(var r of q(t))e.indexOf(r)<0&&G.call(t,r)&&(n[r]=t[r]);return n},l=(t,e,n)=>(M(t,typeof e!="symbol"?e+"":e,n),n),R=(t,e,n)=>new Promise((r,s)=>{var i=o=>{try{h(n.next(o))}catch(c){s(c)}},a=o=>{try{h(n.throw(o))}catch(c){s(c)}},h=o=>o.done?r(o.value):Promise.resolve(o.value).then(i,a);h((n=n.apply(t,e)).next())}),ye="hCaptcha-script",A="hCaptchaOnLoad",z="script-error",w="@hCaptcha/loader";function ve(t){return Object.entries(t).filter(([,e])=>e||e===!1).map(([e,n])=>`${encodeURIComponent(e)}=${encodeURIComponent(String(n))}`).join("&")}function Q(t){let e=t&&t.ownerDocument||document,n=e.defaultView||e.parentWindow||window;return{document:e,window:n}}function Y(t){return t||document.head}function xe(t){var e;t.setTag("source",w),t.setTag("url",document.URL),t.setContext("os",{UA:navigator.userAgent}),t.setContext("browser",m({},be())),t.setContext("device",X(m({},Ee()),{screen_width_pixels:screen.width,screen_height_pixels:screen.height,language:navigator.language,orientation:((e=screen.orientation)==null?void 0:e.type)||"Unknown",processor_count:navigator.hardwareConcurrency,platform:navigator.platform}))}function be(){var t,e,n,r,s,i;let a=navigator.userAgent,h,o;return a.indexOf("Firefox")!==-1?(h="Firefox",o=(t=a.match(/Firefox\/([\d.]+)/))==null?void 0:t[1]):a.indexOf("Edg")!==-1?(h="Microsoft Edge",o=(e=a.match(/Edg\/([\d.]+)/))==null?void 0:e[1]):a.indexOf("Chrome")!==-1&&a.indexOf("Safari")!==-1?(h="Chrome",o=(n=a.match(/Chrome\/([\d.]+)/))==null?void 0:n[1]):a.indexOf("Safari")!==-1&&a.indexOf("Chrome")===-1?(h="Safari",o=(r=a.match(/Version\/([\d.]+)/))==null?void 0:r[1]):a.indexOf("Opera")!==-1||a.indexOf("OPR")!==-1?(h="Opera",o=(s=a.match(/(Opera|OPR)\/([\d.]+)/))==null?void 0:s[2]):a.indexOf("MSIE")!==-1||a.indexOf("Trident")!==-1?(h="Internet Explorer",o=(i=a.match(/(MSIE |rv:)([\d.]+)/))==null?void 0:i[2]):(h="Unknown",o="Unknown"),{name:h,version:o}}function we(t){return new Promise(e=>setTimeout(e,t))}function Ee(){let t=navigator.userAgent,e;t.indexOf("Win")!==-1?e="Windows":t.indexOf("Mac")!==-1?e="Mac":t.indexOf("Linux")!==-1?e="Linux":t.indexOf("Android")!==-1?e="Android":t.indexOf("like Mac")!==-1||t.indexOf("iPhone")!==-1||t.indexOf("iPad")!==-1?e="iOS":e="Unknown";let n;return/Mobile|iPhone|iPod|Android/i.test(t)?n="Mobile":/Tablet|iPad/i.test(t)?n="Tablet":n="Desktop",{model:e,family:e,device:n}}var Ce=class Z{constructor(e){l(this,"_parent"),l(this,"breadcrumbs",[]),l(this,"context",{}),l(this,"extra",{}),l(this,"tags",{}),l(this,"request"),l(this,"user"),this._parent=e}get parent(){return this._parent}child(){return new Z(this)}setRequest(e){return this.request=e,this}removeRequest(){return this.request=void 0,this}addBreadcrumb(e){return typeof e.timestamp>"u"&&(e.timestamp=new Date().toISOString()),this.breadcrumbs.push(e),this}setExtra(e,n){return this.extra[e]=n,this}removeExtra(e){return delete this.extra[e],this}setContext(e,n){return typeof n.type>"u"&&(n.type=e),this.context[e]=n,this}removeContext(e){return delete this.context[e],this}setTags(e){return this.tags=m(m({},this.tags),e),this}setTag(e,n){return this.tags[e]=n,this}removeTag(e){return delete this.tags[e],this}setUser(e){return this.user=e,this}removeUser(){return this.user=void 0,this}toBody(){let e=[],n=this;for(;n;)e.push(n),n=n.parent;return e.reverse().reduce((r,s)=>{var i;return r.breadcrumbs=[...(i=r.breadcrumbs)!=null?i:[],...s.breadcrumbs],r.extra=m(m({},r.extra),s.extra),r.contexts=m(m({},r.contexts),s.context),r.tags=m(m({},r.tags),s.tags),s.user&&(r.user=s.user),s.request&&(r.request=s.request),r},{breadcrumbs:[],extra:{},contexts:{},tags:{},request:void 0,user:void 0})}clear(){this.breadcrumbs=[],this.context={},this.tags={},this.user=void 0}},Re=/^\s*at (?:(.*?) ?\()?((?:file|https?|blob|chrome-extension|address|native|eval|webpack|<anonymous>|[-a-z]+:|.*bundle|\/).*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,_e=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:file|https?|blob|chrome|webpack|resource|moz-extension).*?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js))(?::(\d+))?(?::(\d+))?\s*$/i,Oe=/^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|webpack|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i,Pe=/^(?:(\w+):)\/\/(?:(\w+)(?::(\w+))?@)([\w.-]+)(?::(\d+))?\/(.+)/,k="?",V="An unknown error occurred",Ie="0.0.4";function Se(t){for(let e=0;e<t.length;e++)t[e]=Math.floor(Math.random()*256);return t}function p(t){return(t+256).toString(16).substring(1)}function ke(){let t=Se(new Array(16));return t[6]=t[6]&15|64,t[8]=t[8]&63|128,p(t[0])+p(t[1])+p(t[2])+p(t[3])+"-"+p(t[4])+p(t[5])+"-"+p(t[6])+p(t[7])+"-"+p(t[8])+p(t[9])+"-"+p(t[10])+p(t[11])+p(t[12])+p(t[13])+p(t[14])+p(t[15])}var je=[[Re,"chrome"],[Oe,"winjs"],[_e,"gecko"]];function Ae(t){var e,n,r,s;if(!t.stack)return null;let i=[],a=(r=(n=(e=t.stack).split)==null?void 0:n.call(e,`
2
+ `))!=null?r:[];for(let h=0;h<a.length;++h){let o=null,c=null,u=null;for(let[y,v]of je)if(c=y.exec(a[h]),c){u=v;break}if(!(!c||!u)){if(u==="chrome")o={filename:(s=c[2])!=null&&s.startsWith("address at ")?c[2].substring(11):c[2],function:c[1]||k,lineno:c[3]?+c[3]:null,colno:c[4]?+c[4]:null};else if(u==="winjs")o={filename:c[2],function:c[1]||k,lineno:+c[3],colno:c[4]?+c[4]:null};else if(u==="gecko")h===0&&!c[5]&&t.columnNumber!==void 0&&i.length>0&&(i[0].column=t.columnNumber+1),o={filename:c[3],function:c[1]||k,lineno:c[4]?+c[4]:null,colno:c[5]?+c[5]:null};else continue;!o.function&&o.lineno&&(o.function=k),i.push(o)}}return i.length?i.reverse():null}function qe(t){let e=Ae(t);return{type:t.name,value:t.message,stacktrace:{frames:e??[]}}}function Le(t){let e=Pe.exec(t),n=e?e.slice(1):[];if(n.length!==6)throw new Error("Invalid DSN");let r=n[5].split("/"),s=r.slice(0,-1).join("/");return n[0]+"://"+n[3]+(n[4]?":"+n[4]:"")+(s?"/"+s:"")+"/api/"+r.pop()+"/envelope/?sentry_version=7&sentry_key="+n[1]+(n[2]?"&sentry_secret="+n[2]:"")}function Me(t,e,n){var r,s;let i=m({event_id:ke().replaceAll("-",""),platform:"javascript",sdk:{name:"@hcaptcha/sentry",version:Ie},environment:e,release:n,timestamp:Date.now()/1e3},t.scope.toBody());if(t.type==="exception"){i.message=(s=(r=t.error)==null?void 0:r.message)!=null?s:"Unknown error",i.fingerprint=[i.message];let a=[],h=t.error;for(let o=0;o<5&&h&&(a.push(qe(h)),!(!h.cause||!(h.cause instanceof Error)));o++)h=h.cause;i.exception={values:a.reverse()}}return t.type==="message"&&(i.message=t.message,i.level=t.level),i}function Te(t){if(t instanceof Error)return t;if(typeof t=="string")return new Error(t);if(typeof t=="object"&&t!==null&&!Array.isArray(t)){let n=t,{message:r}=n,s=ge(n,["message"]),i=new Error(typeof r=="string"?r:V);return Object.assign(i,s)}let e=new Error(V);return Object.assign(e,{cause:t})}function Ue(t,e,n){return R(this,null,function*(){var r,s;try{if(typeof fetch<"u"&&typeof AbortSignal<"u"){let i;if(n){let o=new AbortController;i=o.signal,setTimeout(()=>o.abort(),n)}let a=yield fetch(t,X(m({},e),{signal:i})),h=yield a.text();return{status:a.status,body:h}}return yield new Promise((i,a)=>{var h,o;let c=new XMLHttpRequest;if(c.open((h=e?.method)!=null?h:"GET",t),c.onload=()=>i({status:c.status,body:c.responseText}),c.onerror=()=>a(new Error("XHR Network Error")),e?.headers)for(let[u,y]of Object.entries(e.headers))c.setRequestHeader(u,y);if(n){let u=setTimeout(()=>{c.abort(),a(new Error("Request timed out"))},n);c.onloadend=()=>{clearTimeout(u)}}c.send((o=e?.body)==null?void 0:o.toString())})}catch(i){return{status:0,body:(s=(r=i?.toString)==null?void 0:r.call(i))!=null?s:"Unknown error"}}})}var f,T=(f=class{constructor(t){l(this,"apiURL"),l(this,"dsn"),l(this,"environment"),l(this,"release"),l(this,"sampleRate"),l(this,"debug"),l(this,"_scope"),l(this,"shouldBuffer",!1),l(this,"bufferlimit",20),l(this,"buffer",[]);var e,n,r,s,i;this.environment=t.environment,this.release=t.release,this.sampleRate=(e=t.sampleRate)!=null?e:1,this.debug=(n=t.debug)!=null?n:!1,this._scope=(r=t.scope)!=null?r:new Ce,this.apiURL=Le(t.dsn),this.dsn=t.dsn,this.shouldBuffer=(s=t.buffer)!=null?s:!1,this.bufferlimit=(i=t.bufferLimit)!=null?i:20}static init(t){f._instance||(f._instance=new f(t))}static get instance(){if(!f._instance)throw new Error("Sentry has not been initialized");return f._instance}log(...t){this.debug&&console.log(...t)}get scope(){return this._scope}static get scope(){return f.instance.scope}withScope(t){let e=this._scope.child();t(e)}static withScope(t){f.instance.withScope(t)}captureException(t,e){this.captureEvent({type:"exception",level:"error",error:Te(t),scope:e??this._scope})}static captureException(t,e){f.instance.captureException(t,e)}captureMessage(t,e="info",n){this.captureEvent({type:"message",level:e,message:t,scope:n??this._scope})}static captureMessage(t,e="info",n){f.instance.captureMessage(t,e,n)}captureEvent(t){if(Math.random()>=this.sampleRate){this.log("Dropped event due to sample rate");return}if(this.shouldBuffer){if(this.buffer.length>=this.bufferlimit)return;this.buffer.push(t)}else this.sendEvent(t)}sendEvent(t,e=5e3){return R(this,null,function*(){try{this.log("Sending sentry event",t);let n=Me(t,this.environment,this.release),r={event_id:n.event_id,dsn:this.dsn},s={type:"event"},i=JSON.stringify(r)+`
3
3
  `+JSON.stringify(s)+`
4
- `+JSON.stringify(n),a=yield Ue(this.apiURL,{method:"POST",headers:{"Content-Type":"application/x-sentry-envelope"},body:i},e);this.log("Sentry response",a.status),a.status!==200&&(console.log(a.body),console.error("Failed to send event to Sentry",a))}catch(n){console.error("Failed to send event",n)}})}flush(t=5e3){return R(this,null,function*(){try{this.log("Flushing sentry events",this.buffer.length);let e=this.buffer.splice(0,this.buffer.length).map(n=>this.sendEvent(n,t));yield Promise.all(e),this.log("Flushed all events")}catch(e){console.error("Failed to flush events",e)}})}static flush(t=5e3){return f.instance.flush(t)}static reset(){f._instance=void 0}},l(f,"_instance"),f),He="https://d233059272824702afc8c43834c4912d@sentry.hcaptcha.com/6",Be="2.3.0",De="production";function $e(t=!0){if(!t)return J();T.init({dsn:He,release:Be,environment:De});let e=T.scope;return xe(e),J(e)}function J(t=null){return{addBreadcrumb:e=>{t&&t.addBreadcrumb(e)},captureRequest:e=>{t&&t.setRequest(e)},captureException:e=>{t&&T.captureException(e,t)}}}function Fe({scriptLocation:t,query:e,loadAsync:n=!0,crossOrigin:r="anonymous",apihost:s="https://js.hcaptcha.com",cleanup:i=!1,secureApi:a=!1,scriptSource:h=""}={},o){let c=Y(t),u=Q(c);return new Promise((y,v)=>{let d=u.document.createElement("script");d.id=ye,h?d.src=`${h}?onload=${A}`:a?d.src=`${s}/1/secure-api.js?onload=${A}`:d.src=`${s}/1/api.js?onload=${A}`,d.crossOrigin=r,d.async=n;let E=(x,C)=>{try{!a&&i&&c.removeChild(d),C(x)}catch(S){v(S)}};d.onload=x=>E(x,y),d.onerror=x=>{o&&o(d.src),E(x,v)},d.src+=e!==""?`&${e}`:"",c.appendChild(d)})}var j=[];function Ne(t={cleanup:!1},e){try{e.addBreadcrumb({category:w,message:"hCaptcha loader params",data:t});let n=Y(t.scriptLocation),r=Q(n),s=j.find(({scope:a})=>a===r.window);if(s)return e.addBreadcrumb({category:w,message:"hCaptcha already loaded"}),s.promise;let i=new Promise((a,h)=>R(this,null,function*(){try{r.window[A]=()=>{e.addBreadcrumb({category:w,message:"hCaptcha script called onload function"}),a(r.window.hcaptcha)};let o=ve({custom:t.custom,render:t.render,sentry:t.sentry,assethost:t.assethost,imghost:t.imghost,reportapi:t.reportapi,endpoint:t.endpoint,host:t.host,recaptchacompat:t.recaptchacompat,hl:t.hl,uj:t.uj});yield Fe(m({query:o},t),c=>{e.captureRequest({url:c,method:"GET"})}),e.addBreadcrumb({category:w,message:"hCaptcha loaded",data:s})}catch{e.addBreadcrumb({category:w,message:"hCaptcha failed to load"});let c=j.findIndex(u=>u.scope===r.window);c!==-1&&j.splice(c,1),h(new Error(z))}}));return j.push({promise:i,scope:r.window}),i}catch(n){return e.captureException(n),Promise.reject(new Error(z))}}function ee(t,e,n=0){return R(this,null,function*(){var r,s;let i=(r=t.maxRetries)!=null?r:2,a=(s=t.retryDelay)!=null?s:1e3,h=n<i?"Retry loading hCaptcha Api":"Exceeded maximum retries";try{return yield Ne(t,e)}catch(o){return e.addBreadcrumb({category:w,message:h}),n>=i?(e.captureException(o),Promise.reject(o)):(e.addBreadcrumb({category:w,message:`Waiting ${a}ms before retry attempt ${n+1}`}),yield we(a),n+=1,ee(t,e,n))}})}function te(){return R(this,arguments,function*(t={}){let e=$e(t.sentry);return yield ee(t,e)})}function U(t){let e=t&&t.ownerDocument||document,n=e.defaultView||e.parentWindow||window;return{document:e,window:n}}function H(t){return t||document.head}var _=class extends O.Component{constructor(e){super(e),this._hcaptcha=void 0,this.renderCaptcha=this.renderCaptcha.bind(this),this.resetCaptcha=this.resetCaptcha.bind(this),this.removeCaptcha=this.removeCaptcha.bind(this),this.isReady=this.isReady.bind(this),this._onReady=null,this.loadCaptcha=this.loadCaptcha.bind(this),this.handleOnLoad=this.handleOnLoad.bind(this),this.handleSubmit=this.handleSubmit.bind(this),this.handleExpire=this.handleExpire.bind(this),this.handleError=this.handleError.bind(this),this.handleOpen=this.handleOpen.bind(this),this.handleClose=this.handleClose.bind(this),this.handleChallengeExpired=this.handleChallengeExpired.bind(this),this.ref=O.createRef(),this.apiScriptRequested=!1,this.sentryHub=null,this.captchaId="",this._pendingExecute=null,this.state={isApiReady:!1,isRemoved:!1,elementId:e.id}}componentDidMount(){let e=H(this.props.scriptLocation),n=U(e);if(this._hcaptcha=n.window.hcaptcha||void 0,typeof this._hcaptcha<"u"){this.setState({isApiReady:!0},()=>{this.renderCaptcha()});return}this.loadCaptcha()}componentWillUnmount(){let e=this._hcaptcha,n=this.captchaId;this._cancelPendingExecute("react-component-unmounted"),this.isReady()&&(e.reset(n),e.remove(n))}shouldComponentUpdate(e,n){return!(this.state.isApiReady!==n.isApiReady||this.state.isRemoved!==n.isRemoved)}componentDidUpdate(e){["sitekey","size","theme","tabindex","languageOverride","endpoint"].every(s=>e[s]===this.props[s])||this.removeCaptcha(()=>{this.renderCaptcha()})}loadCaptcha(){if(this.apiScriptRequested)return;let{apihost:e,assethost:n,endpoint:r,host:s,imghost:i,languageOverride:a,reCaptchaCompat:h,reportapi:o,sentry:c,custom:u,loadAsync:y,scriptLocation:v,scriptSource:d,secureApi:E,cleanup:x=!0,userJourneys:C}=this.props;te({render:"explicit",apihost:e,assethost:n,endpoint:r,hl:a,host:s,imghost:i,recaptchacompat:h===!1?"off":null,reportapi:o,sentry:c,custom:u,loadAsync:y,scriptLocation:v,scriptSource:d,secureApi:E,cleanup:x,uj:C!==void 0?C:!1}).then(this.handleOnLoad,this.handleError).catch(this.handleError),this.apiScriptRequested=!0}renderCaptcha(e){let{onReady:n}=this.props,{isApiReady:r}=this.state,s=this.captchaId;if(!r||s)return;let i=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}),h=this._hcaptcha.render(this.ref.current,i);this.captchaId=h,this.setState({isRemoved:!1},()=>{e&&e(),n&&n(),this._onReady&&this._onReady(h)})}resetCaptcha(){let e=this._hcaptcha,n=this.captchaId;this.isReady()&&(e.reset(n),this._cancelPendingExecute("hcaptcha-reset"))}removeCaptcha(e){let n=this._hcaptcha,r=this.captchaId;this._cancelPendingExecute("hcaptcha-removed"),this.isReady()&&this.setState({isRemoved:!0},()=>{this.captchaId="",n.remove(r),e&&e()})}handleOnLoad(){this.setState({isApiReady:!0},()=>{let e=H(this.props.scriptLocation),n=U(e);this._hcaptcha=n.window.hcaptcha,this.renderCaptcha(()=>{let{onLoad:r}=this.props;r&&r()})})}handleSubmit(e){let{onVerify:n}=this.props,{isRemoved:r}=this.state,s=this._hcaptcha,i=this.captchaId;if(typeof s>"u"||r)return;let a=s.getResponse(i),h=s.getRespKey(i);n&&n(a,h)}handleExpire(){let{onExpire:e}=this.props,n=this._hcaptcha,r=this.captchaId;this.isReady()&&(n.reset(r),e&&e())}handleError(e){let{onError:n}=this.props,r=this._hcaptcha,s=this.captchaId;this.isReady()&&r.reset(s),n&&n(e)}isReady(){let{isApiReady:e,isRemoved:n}=this.state;return e&&!n}_cancelPendingExecute(e){if(!this._pendingExecute)return;let n=this._pendingExecute;this._pendingExecute=null;let r=new Error(e);n.reject(r)}handleOpen(){!this.isReady()||!this.props.onOpen||this.props.onOpen()}handleClose(){!this.isReady()||!this.props.onClose||this.props.onClose()}handleChallengeExpired(){!this.isReady()||!this.props.onChalExpired||this.props.onChalExpired()}execute(e=null){e=typeof e=="object"?e:null;try{let n=this._hcaptcha,r=this.captchaId;if(e&&e.async&&this._pendingExecute&&this._cancelPendingExecute("hcaptcha-execute-replaced"),!this.isReady())return e&&e.async?new Promise((i,a)=>{this._pendingExecute={resolve:i,reject:a},this._onReady=h=>{if(this._pendingExecute)try{let o=n.execute(h,e);o&&typeof o.then=="function"?o.then(c=>{this._pendingExecute=null,i(c)}).catch(c=>{this._pendingExecute=null,a(c)}):(this._pendingExecute=null,a(new Error("hcaptcha-execute-no-promise")))}catch(o){this._pendingExecute=null,a(o)}}}):(this._onReady=i=>{n.execute(i,e)},null);let s=n.execute(r,e);return e&&e.async&&s&&typeof s.then=="function"?new Promise((i,a)=>{this._pendingExecute={resolve:i,reject:a},s.then(h=>{this._pendingExecute=null,i(h)}).catch(h=>{this._pendingExecute=null,a(h)})}):s}catch(n){return e&&e.async?Promise.reject(n):null}}close(){let e=this._hcaptcha,n=this.captchaId;if(this._cancelPendingExecute("hcaptcha-closed"),!!this.isReady())return e.close(n)}setData(e){let n=this._hcaptcha,r=this.captchaId;this.isReady()&&(e&&typeof e!="object"&&(e=null),n.setData(r,e))}getResponse(){return this._hcaptcha.getResponse(this.captchaId)}getRespKey(){return this._hcaptcha.getRespKey(this.captchaId)}render(){let{elementId:e}=this.state;return O.createElement("div",{ref:this.ref,id:e})}};var re=require("react");var ne=require("react"),L=(0,ne.createContext)();var B=()=>(0,re.useContext)(L);var g=W(require("react"),1);function D({sitekey:t=null,size:e="normal",theme:n="light",rqdata:r=null,languageOverride:s=null,onVerify:i,onError:a,children:h}){let o=(0,g.useRef)(null),[c,u]=(0,g.useState)(!1),[y,v]=(0,g.useState)(null),[d,E]=(0,g.useState)(null),x=()=>{u(!0)},C=b=>{E(b),a&&a(b)},S=()=>{v(null)},se=b=>{v(b),i&&i(b)},ie=async(b={})=>{try{if(!c)throw new Error("hCaptcha not ready");y&&F();let{response:P}=await o.current.execute({async:!0,...b.rqdata?{rqdata:b.rqdata}:{}});return v(P),P}catch(P){E(P),a&&a(P)}},F=()=>{o?.current?.resetCaptcha()};return(0,g.useEffect)(()=>{r&&o?.current?.setData(r)},[r]),g.default.createElement(L.Provider,{value:{sitekey:t,error:d,token:y,ready:c,executeInstance:ie,resetInstance:F}},h,g.default.createElement($,{sitekey:t,size:e,theme:n,languageOverride:s,onReady:x,onVerify:se,onExpire:S,onError:C,ref:o}))}var $=_;
4
+ `+JSON.stringify(n),a=yield Ue(this.apiURL,{method:"POST",headers:{"Content-Type":"application/x-sentry-envelope"},body:i},e);this.log("Sentry response",a.status),a.status!==200&&(console.log(a.body),console.error("Failed to send event to Sentry",a))}catch(n){console.error("Failed to send event",n)}})}flush(t=5e3){return R(this,null,function*(){try{this.log("Flushing sentry events",this.buffer.length);let e=this.buffer.splice(0,this.buffer.length).map(n=>this.sendEvent(n,t));yield Promise.all(e),this.log("Flushed all events")}catch(e){console.error("Failed to flush events",e)}})}static flush(t=5e3){return f.instance.flush(t)}static reset(){f._instance=void 0}},l(f,"_instance"),f),He="https://d233059272824702afc8c43834c4912d@sentry.hcaptcha.com/6",Be="2.3.0",De="production";function $e(t=!0){if(!t)return J();T.init({dsn:He,release:Be,environment:De});let e=T.scope;return xe(e),J(e)}function J(t=null){return{addBreadcrumb:e=>{t&&t.addBreadcrumb(e)},captureRequest:e=>{t&&t.setRequest(e)},captureException:e=>{t&&T.captureException(e,t)}}}function Fe({scriptLocation:t,query:e,loadAsync:n=!0,crossOrigin:r="anonymous",apihost:s="https://js.hcaptcha.com",cleanup:i=!1,secureApi:a=!1,scriptSource:h=""}={},o){let c=Y(t),u=Q(c);return new Promise((y,v)=>{let d=u.document.createElement("script");d.id=ye,h?d.src=`${h}?onload=${A}`:a?d.src=`${s}/1/secure-api.js?onload=${A}`:d.src=`${s}/1/api.js?onload=${A}`,d.crossOrigin=r,d.async=n;let E=(x,C)=>{try{!a&&i&&c.removeChild(d),C(x)}catch(I){v(I)}};d.onload=x=>E(x,y),d.onerror=x=>{o&&o(d.src),E(x,v)},d.src+=e!==""?`&${e}`:"",c.appendChild(d)})}var j=[];function Ne(t={cleanup:!1},e){try{e.addBreadcrumb({category:w,message:"hCaptcha loader params",data:t});let n=Y(t.scriptLocation),r=Q(n),s=j.find(({scope:a})=>a===r.window);if(s)return e.addBreadcrumb({category:w,message:"hCaptcha already loaded"}),s.promise;let i=new Promise((a,h)=>R(this,null,function*(){try{r.window[A]=()=>{e.addBreadcrumb({category:w,message:"hCaptcha script called onload function"}),a(r.window.hcaptcha)};let o=ve({custom:t.custom,render:t.render,sentry:t.sentry,assethost:t.assethost,imghost:t.imghost,reportapi:t.reportapi,endpoint:t.endpoint,host:t.host,recaptchacompat:t.recaptchacompat,hl:t.hl,uj:t.uj});yield Fe(m({query:o},t),c=>{e.captureRequest({url:c,method:"GET"})}),e.addBreadcrumb({category:w,message:"hCaptcha loaded",data:s})}catch{e.addBreadcrumb({category:w,message:"hCaptcha failed to load"});let c=j.findIndex(u=>u.scope===r.window);c!==-1&&j.splice(c,1),h(new Error(z))}}));return j.push({promise:i,scope:r.window}),i}catch(n){return e.captureException(n),Promise.reject(new Error(z))}}function ee(t,e,n=0){return R(this,null,function*(){var r,s;let i=(r=t.maxRetries)!=null?r:2,a=(s=t.retryDelay)!=null?s:1e3,h=n<i?"Retry loading hCaptcha Api":"Exceeded maximum retries";try{return yield Ne(t,e)}catch(o){return e.addBreadcrumb({category:w,message:h}),n>=i?(e.captureException(o),Promise.reject(o)):(e.addBreadcrumb({category:w,message:`Waiting ${a}ms before retry attempt ${n+1}`}),yield we(a),n+=1,ee(t,e,n))}})}function te(){return R(this,arguments,function*(t={}){let e=$e(t.sentry);return yield ee(t,e)})}function U(t){let e=t&&t.ownerDocument||document,n=e.defaultView||e.parentWindow||window;return{document:e,window:n}}function H(t){return t||document.head}var _=class extends O.Component{constructor(e){super(e),this._hcaptcha=void 0,this.renderCaptcha=this.renderCaptcha.bind(this),this.resetCaptcha=this.resetCaptcha.bind(this),this.removeCaptcha=this.removeCaptcha.bind(this),this.isReady=this.isReady.bind(this),this._onReady=null,this.loadCaptcha=this.loadCaptcha.bind(this),this.handleOnLoad=this.handleOnLoad.bind(this),this.handleSubmit=this.handleSubmit.bind(this),this.handleExpire=this.handleExpire.bind(this),this.handleError=this.handleError.bind(this),this.handleOpen=this.handleOpen.bind(this),this.handleClose=this.handleClose.bind(this),this.handleChallengeExpired=this.handleChallengeExpired.bind(this),this.ref=O.createRef(),this.apiScriptRequested=!1,this.sentryHub=null,this.captchaId="",this._pendingExecute=null,this.state={isApiReady:!1,isRemoved:!1,elementId:e.id}}componentDidMount(){let e=H(this.props.scriptLocation),n=U(e);if(this._hcaptcha=n.window.hcaptcha||void 0,typeof this._hcaptcha<"u"){this.setState({isApiReady:!0},()=>{this.renderCaptcha()});return}this.loadCaptcha()}componentWillUnmount(){let e=this._hcaptcha,n=this.captchaId;if(this._cancelPendingExecute("react-component-unmounted"),!!this.isReady())try{e.reset(n),e.remove(n)}catch{}finally{this.captchaId="",this._onReady=null}}shouldComponentUpdate(e,n){return!(this.state.isApiReady!==n.isApiReady||this.state.isRemoved!==n.isRemoved)}componentDidUpdate(e){["sitekey","size","theme","tabindex","languageOverride","endpoint"].every(s=>e[s]===this.props[s])||this.removeCaptcha(()=>{this.renderCaptcha()})}loadCaptcha(){if(this.apiScriptRequested)return;let{apihost:e,assethost:n,endpoint:r,host:s,imghost:i,languageOverride:a,reCaptchaCompat:h,reportapi:o,sentry:c,custom:u,loadAsync:y,scriptLocation:v,scriptSource:d,secureApi:E,cleanup:x=!0,userJourneys:C}=this.props;te({render:"explicit",apihost:e,assethost:n,endpoint:r,hl:a,host:s,imghost:i,recaptchacompat:h===!1?"off":null,reportapi:o,sentry:c,custom:u,loadAsync:y,scriptLocation:v,scriptSource:d,secureApi:E,cleanup:x,uj:C!==void 0?C:!1}).then(this.handleOnLoad,this.handleError).catch(this.handleError),this.apiScriptRequested=!0}renderCaptcha(e){let{onReady:n}=this.props,{isApiReady:r}=this.state,s=this.captchaId;if(!r||s)return;let i=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}),h=this._hcaptcha.render(this.ref.current,i);this.captchaId=h,this.setState({isRemoved:!1},()=>{e&&e(),n&&n(),this._onReady&&this._onReady(h)})}resetCaptcha(){let e=this._hcaptcha,n=this.captchaId;this.isReady()&&(e.reset(n),this._cancelPendingExecute("hcaptcha-reset"))}removeCaptcha(e){let n=this._hcaptcha,r=this.captchaId;this._cancelPendingExecute("hcaptcha-removed"),this.isReady()&&this.setState({isRemoved:!0},()=>{this.captchaId="",n.remove(r),e&&e()})}handleOnLoad(){this.setState({isApiReady:!0},()=>{let e=H(this.props.scriptLocation),n=U(e);this._hcaptcha=n.window.hcaptcha,this.renderCaptcha(()=>{let{onLoad:r}=this.props;r&&r()})})}handleSubmit(e){let{onVerify:n}=this.props,{isRemoved:r}=this.state,s=this._hcaptcha,i=this.captchaId;if(typeof s>"u"||r)return;let a=s.getResponse(i),h=s.getRespKey(i);n&&n(a,h)}handleExpire(){let{onExpire:e}=this.props,n=this._hcaptcha,r=this.captchaId;this.isReady()&&(n.reset(r),e&&e())}handleError(e){let{onError:n}=this.props,r=this._hcaptcha,s=this.captchaId;this.isReady()&&r.reset(s),n&&n(e)}isReady(){let{isApiReady:e,isRemoved:n}=this.state;return e&&!n}_cancelPendingExecute(e){if(!this._pendingExecute)return;let n=this._pendingExecute;this._pendingExecute=null;let r=new Error(e);n.reject(r)}handleOpen(){!this.isReady()||!this.props.onOpen||this.props.onOpen()}handleClose(){!this.isReady()||!this.props.onClose||this.props.onClose()}handleChallengeExpired(){!this.isReady()||!this.props.onChalExpired||this.props.onChalExpired()}execute(e=null){e=typeof e=="object"?e:null;try{let n=this._hcaptcha,r=this.captchaId;if(e&&e.async&&this._pendingExecute&&this._cancelPendingExecute("hcaptcha-execute-replaced"),!this.isReady())return e&&e.async?new Promise((i,a)=>{this._pendingExecute={resolve:i,reject:a},this._onReady=h=>{if(this._pendingExecute)try{let o=n.execute(h,e);o&&typeof o.then=="function"?o.then(c=>{this._pendingExecute=null,i(c)}).catch(c=>{this._pendingExecute=null,a(c)}):(this._pendingExecute=null,a(new Error("hcaptcha-execute-no-promise")))}catch(o){this._pendingExecute=null,a(o)}}}):(this._onReady=i=>{n.execute(i,e)},null);let s=n.execute(r,e);return e&&e.async&&s&&typeof s.then=="function"?new Promise((i,a)=>{this._pendingExecute={resolve:i,reject:a},s.then(h=>{this._pendingExecute=null,i(h)}).catch(h=>{this._pendingExecute=null,a(h)})}):s}catch(n){return e&&e.async?Promise.reject(n):null}}close(){let e=this._hcaptcha,n=this.captchaId;if(this._cancelPendingExecute("hcaptcha-closed"),!!this.isReady())return e.close(n)}setData(e){let n=this._hcaptcha,r=this.captchaId;this.isReady()&&(e&&typeof e!="object"&&(e=null),n.setData(r,e))}getResponse(){return this._hcaptcha.getResponse(this.captchaId)}getRespKey(){return this._hcaptcha.getRespKey(this.captchaId)}render(){let{elementId:e}=this.state;return O.createElement("div",{ref:this.ref,id:e})}};var re=require("react");var ne=require("react"),L=(0,ne.createContext)();var B=()=>(0,re.useContext)(L);var g=W(require("react"),1);function D({sitekey:t=null,size:e="normal",theme:n="light",rqdata:r=null,languageOverride:s=null,onVerify:i,onError:a,children:h}){let o=(0,g.useRef)(null),[c,u]=(0,g.useState)(!1),[y,v]=(0,g.useState)(null),[d,E]=(0,g.useState)(null),x=()=>{u(!0)},C=b=>{E(b),a&&a(b)},I=()=>{v(null)},se=b=>{v(b),i&&i(b)},ie=async(b={})=>{try{if(!c)throw new Error("hCaptcha not ready");y&&F();let{response:P}=await o.current.execute({async:!0,...b.rqdata?{rqdata:b.rqdata}:{}});return v(P),P}catch(P){E(P),a&&a(P)}},F=()=>{o?.current?.resetCaptcha()};return(0,g.useEffect)(()=>{r&&o?.current?.setData(r)},[r]),g.default.createElement(L.Provider,{value:{sitekey:t,error:d,token:y,ready:c,executeInstance:ie,resetInstance:F}},h,g.default.createElement($,{sitekey:t,size:e,theme:n,languageOverride:s,onReady:x,onVerify:se,onExpire:I,onError:C,ref:o}))}var $=_;
@@ -1,4 +1,4 @@
1
- var ae=Object.defineProperty;var B=Object.getOwnPropertySymbols;var oe=Object.prototype.hasOwnProperty,ce=Object.prototype.propertyIsEnumerable;var D=(t,e,n)=>e in t?ae(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,$=(t,e)=>{for(var n in e||(e={}))oe.call(e,n)&&D(t,n,e[n]);if(B)for(var n of B(e))ce.call(e,n)&&D(t,n,e[n]);return t};var F=(t,e,n)=>new Promise((r,i)=>{var a=s=>{try{h(n.next(s))}catch(c){i(c)}},o=s=>{try{h(n.throw(s))}catch(c){i(c)}},h=s=>s.done?r(s.value):Promise.resolve(s.value).then(a,o);h((n=n.apply(t,e)).next())});import{useContext as le}from"react";import{createContext as he}from"react";var S=he();var N=()=>le(S);import re,{useEffect as Fe,useRef as Ne,useState as U}from"react";import*as R from"react";var ue=Object.defineProperty,de=Object.defineProperties,pe=Object.getOwnPropertyDescriptors,A=Object.getOwnPropertySymbols,J=Object.prototype.hasOwnProperty,K=Object.prototype.propertyIsEnumerable,q=(t,e,n)=>e in t?ue(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,g=(t,e)=>{for(var n in e||(e={}))J.call(e,n)&&q(t,n,e[n]);if(A)for(var n of A(e))K.call(e,n)&&q(t,n,e[n]);return t},G=(t,e)=>de(t,pe(e)),fe=(t,e)=>{var n={};for(var r in t)J.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&A)for(var r of A(t))e.indexOf(r)<0&&K.call(t,r)&&(n[r]=t[r]);return n},l=(t,e,n)=>(q(t,typeof e!="symbol"?e+"":e,n),n),C=(t,e,n)=>new Promise((r,i)=>{var a=s=>{try{h(n.next(s))}catch(c){i(c)}},o=s=>{try{h(n.throw(s))}catch(c){i(c)}},h=s=>s.done?r(s.value):Promise.resolve(s.value).then(a,o);h((n=n.apply(t,e)).next())}),me="hCaptcha-script",j="hCaptchaOnLoad",W="script-error",b="@hCaptcha/loader";function ge(t){return Object.entries(t).filter(([,e])=>e||e===!1).map(([e,n])=>`${encodeURIComponent(e)}=${encodeURIComponent(String(n))}`).join("&")}function X(t){let e=t&&t.ownerDocument||document,n=e.defaultView||e.parentWindow||window;return{document:e,window:n}}function Q(t){return t||document.head}function ye(t){var e;t.setTag("source",b),t.setTag("url",document.URL),t.setContext("os",{UA:navigator.userAgent}),t.setContext("browser",g({},ve())),t.setContext("device",G(g({},be()),{screen_width_pixels:screen.width,screen_height_pixels:screen.height,language:navigator.language,orientation:((e=screen.orientation)==null?void 0:e.type)||"Unknown",processor_count:navigator.hardwareConcurrency,platform:navigator.platform}))}function ve(){var t,e,n,r,i,a;let o=navigator.userAgent,h,s;return o.indexOf("Firefox")!==-1?(h="Firefox",s=(t=o.match(/Firefox\/([\d.]+)/))==null?void 0:t[1]):o.indexOf("Edg")!==-1?(h="Microsoft Edge",s=(e=o.match(/Edg\/([\d.]+)/))==null?void 0:e[1]):o.indexOf("Chrome")!==-1&&o.indexOf("Safari")!==-1?(h="Chrome",s=(n=o.match(/Chrome\/([\d.]+)/))==null?void 0:n[1]):o.indexOf("Safari")!==-1&&o.indexOf("Chrome")===-1?(h="Safari",s=(r=o.match(/Version\/([\d.]+)/))==null?void 0:r[1]):o.indexOf("Opera")!==-1||o.indexOf("OPR")!==-1?(h="Opera",s=(i=o.match(/(Opera|OPR)\/([\d.]+)/))==null?void 0:i[2]):o.indexOf("MSIE")!==-1||o.indexOf("Trident")!==-1?(h="Internet Explorer",s=(a=o.match(/(MSIE |rv:)([\d.]+)/))==null?void 0:a[2]):(h="Unknown",s="Unknown"),{name:h,version:s}}function xe(t){return new Promise(e=>setTimeout(e,t))}function be(){let t=navigator.userAgent,e;t.indexOf("Win")!==-1?e="Windows":t.indexOf("Mac")!==-1?e="Mac":t.indexOf("Linux")!==-1?e="Linux":t.indexOf("Android")!==-1?e="Android":t.indexOf("like Mac")!==-1||t.indexOf("iPhone")!==-1||t.indexOf("iPad")!==-1?e="iOS":e="Unknown";let n;return/Mobile|iPhone|iPod|Android/i.test(t)?n="Mobile":/Tablet|iPad/i.test(t)?n="Tablet":n="Desktop",{model:e,family:e,device:n}}var we=class Y{constructor(e){l(this,"_parent"),l(this,"breadcrumbs",[]),l(this,"context",{}),l(this,"extra",{}),l(this,"tags",{}),l(this,"request"),l(this,"user"),this._parent=e}get parent(){return this._parent}child(){return new Y(this)}setRequest(e){return this.request=e,this}removeRequest(){return this.request=void 0,this}addBreadcrumb(e){return typeof e.timestamp>"u"&&(e.timestamp=new Date().toISOString()),this.breadcrumbs.push(e),this}setExtra(e,n){return this.extra[e]=n,this}removeExtra(e){return delete this.extra[e],this}setContext(e,n){return typeof n.type>"u"&&(n.type=e),this.context[e]=n,this}removeContext(e){return delete this.context[e],this}setTags(e){return this.tags=g(g({},this.tags),e),this}setTag(e,n){return this.tags[e]=n,this}removeTag(e){return delete this.tags[e],this}setUser(e){return this.user=e,this}removeUser(){return this.user=void 0,this}toBody(){let e=[],n=this;for(;n;)e.push(n),n=n.parent;return e.reverse().reduce((r,i)=>{var a;return r.breadcrumbs=[...(a=r.breadcrumbs)!=null?a:[],...i.breadcrumbs],r.extra=g(g({},r.extra),i.extra),r.contexts=g(g({},r.contexts),i.context),r.tags=g(g({},r.tags),i.tags),i.user&&(r.user=i.user),i.request&&(r.request=i.request),r},{breadcrumbs:[],extra:{},contexts:{},tags:{},request:void 0,user:void 0})}clear(){this.breadcrumbs=[],this.context={},this.tags={},this.user=void 0}},Ee=/^\s*at (?:(.*?) ?\()?((?:file|https?|blob|chrome-extension|address|native|eval|webpack|<anonymous>|[-a-z]+:|.*bundle|\/).*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,Ce=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:file|https?|blob|chrome|webpack|resource|moz-extension).*?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js))(?::(\d+))?(?::(\d+))?\s*$/i,Re=/^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|webpack|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i,_e=/^(?:(\w+):)\/\/(?:(\w+)(?::(\w+))?@)([\w.-]+)(?::(\d+))?\/(.+)/,I="?",z="An unknown error occurred",Oe="0.0.4";function Pe(t){for(let e=0;e<t.length;e++)t[e]=Math.floor(Math.random()*256);return t}function p(t){return(t+256).toString(16).substring(1)}function Se(){let t=Pe(new Array(16));return t[6]=t[6]&15|64,t[8]=t[8]&63|128,p(t[0])+p(t[1])+p(t[2])+p(t[3])+"-"+p(t[4])+p(t[5])+"-"+p(t[6])+p(t[7])+"-"+p(t[8])+p(t[9])+"-"+p(t[10])+p(t[11])+p(t[12])+p(t[13])+p(t[14])+p(t[15])}var Ie=[[Ee,"chrome"],[Re,"winjs"],[Ce,"gecko"]];function ke(t){var e,n,r,i;if(!t.stack)return null;let a=[],o=(r=(n=(e=t.stack).split)==null?void 0:n.call(e,`
2
- `))!=null?r:[];for(let h=0;h<o.length;++h){let s=null,c=null,u=null;for(let[y,v]of Ie)if(c=y.exec(o[h]),c){u=v;break}if(!(!c||!u)){if(u==="chrome")s={filename:(i=c[2])!=null&&i.startsWith("address at ")?c[2].substring(11):c[2],function:c[1]||I,lineno:c[3]?+c[3]:null,colno:c[4]?+c[4]:null};else if(u==="winjs")s={filename:c[2],function:c[1]||I,lineno:+c[3],colno:c[4]?+c[4]:null};else if(u==="gecko")h===0&&!c[5]&&t.columnNumber!==void 0&&a.length>0&&(a[0].column=t.columnNumber+1),s={filename:c[3],function:c[1]||I,lineno:c[4]?+c[4]:null,colno:c[5]?+c[5]:null};else continue;!s.function&&s.lineno&&(s.function=I),a.push(s)}}return a.length?a.reverse():null}function je(t){let e=ke(t);return{type:t.name,value:t.message,stacktrace:{frames:e!=null?e:[]}}}function Ae(t){let e=_e.exec(t),n=e?e.slice(1):[];if(n.length!==6)throw new Error("Invalid DSN");let r=n[5].split("/"),i=r.slice(0,-1).join("/");return n[0]+"://"+n[3]+(n[4]?":"+n[4]:"")+(i?"/"+i:"")+"/api/"+r.pop()+"/envelope/?sentry_version=7&sentry_key="+n[1]+(n[2]?"&sentry_secret="+n[2]:"")}function qe(t,e,n){var r,i;let a=g({event_id:Se().replaceAll("-",""),platform:"javascript",sdk:{name:"@hcaptcha/sentry",version:Oe},environment:e,release:n,timestamp:Date.now()/1e3},t.scope.toBody());if(t.type==="exception"){a.message=(i=(r=t.error)==null?void 0:r.message)!=null?i:"Unknown error",a.fingerprint=[a.message];let o=[],h=t.error;for(let s=0;s<5&&h&&(o.push(je(h)),!(!h.cause||!(h.cause instanceof Error)));s++)h=h.cause;a.exception={values:o.reverse()}}return t.type==="message"&&(a.message=t.message,a.level=t.level),a}function Le(t){if(t instanceof Error)return t;if(typeof t=="string")return new Error(t);if(typeof t=="object"&&t!==null&&!Array.isArray(t)){let n=t,{message:r}=n,i=fe(n,["message"]),a=new Error(typeof r=="string"?r:z);return Object.assign(a,i)}let e=new Error(z);return Object.assign(e,{cause:t})}function Me(t,e,n){return C(this,null,function*(){var r,i;try{if(typeof fetch<"u"&&typeof AbortSignal<"u"){let a;if(n){let s=new AbortController;a=s.signal,setTimeout(()=>s.abort(),n)}let o=yield fetch(t,G(g({},e),{signal:a})),h=yield o.text();return{status:o.status,body:h}}return yield new Promise((a,o)=>{var h,s;let c=new XMLHttpRequest;if(c.open((h=e==null?void 0:e.method)!=null?h:"GET",t),c.onload=()=>a({status:c.status,body:c.responseText}),c.onerror=()=>o(new Error("XHR Network Error")),e==null?void 0:e.headers)for(let[u,y]of Object.entries(e.headers))c.setRequestHeader(u,y);if(n){let u=setTimeout(()=>{c.abort(),o(new Error("Request timed out"))},n);c.onloadend=()=>{clearTimeout(u)}}c.send((s=e==null?void 0:e.body)==null?void 0:s.toString())})}catch(a){return{status:0,body:(i=(r=a==null?void 0:a.toString)==null?void 0:r.call(a))!=null?i:"Unknown error"}}})}var m,L=(m=class{constructor(t){l(this,"apiURL"),l(this,"dsn"),l(this,"environment"),l(this,"release"),l(this,"sampleRate"),l(this,"debug"),l(this,"_scope"),l(this,"shouldBuffer",!1),l(this,"bufferlimit",20),l(this,"buffer",[]);var e,n,r,i,a;this.environment=t.environment,this.release=t.release,this.sampleRate=(e=t.sampleRate)!=null?e:1,this.debug=(n=t.debug)!=null?n:!1,this._scope=(r=t.scope)!=null?r:new we,this.apiURL=Ae(t.dsn),this.dsn=t.dsn,this.shouldBuffer=(i=t.buffer)!=null?i:!1,this.bufferlimit=(a=t.bufferLimit)!=null?a:20}static init(t){m._instance||(m._instance=new m(t))}static get instance(){if(!m._instance)throw new Error("Sentry has not been initialized");return m._instance}log(...t){this.debug&&console.log(...t)}get scope(){return this._scope}static get scope(){return m.instance.scope}withScope(t){let e=this._scope.child();t(e)}static withScope(t){m.instance.withScope(t)}captureException(t,e){this.captureEvent({type:"exception",level:"error",error:Le(t),scope:e!=null?e:this._scope})}static captureException(t,e){m.instance.captureException(t,e)}captureMessage(t,e="info",n){this.captureEvent({type:"message",level:e,message:t,scope:n!=null?n:this._scope})}static captureMessage(t,e="info",n){m.instance.captureMessage(t,e,n)}captureEvent(t){if(Math.random()>=this.sampleRate){this.log("Dropped event due to sample rate");return}if(this.shouldBuffer){if(this.buffer.length>=this.bufferlimit)return;this.buffer.push(t)}else this.sendEvent(t)}sendEvent(t,e=5e3){return C(this,null,function*(){try{this.log("Sending sentry event",t);let n=qe(t,this.environment,this.release),r={event_id:n.event_id,dsn:this.dsn},i={type:"event"},a=JSON.stringify(r)+`
1
+ var ae=Object.defineProperty;var B=Object.getOwnPropertySymbols;var oe=Object.prototype.hasOwnProperty,ce=Object.prototype.propertyIsEnumerable;var D=(t,e,n)=>e in t?ae(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,$=(t,e)=>{for(var n in e||(e={}))oe.call(e,n)&&D(t,n,e[n]);if(B)for(var n of B(e))ce.call(e,n)&&D(t,n,e[n]);return t};var F=(t,e,n)=>new Promise((r,i)=>{var a=s=>{try{h(n.next(s))}catch(c){i(c)}},o=s=>{try{h(n.throw(s))}catch(c){i(c)}},h=s=>s.done?r(s.value):Promise.resolve(s.value).then(a,o);h((n=n.apply(t,e)).next())});import{useContext as le}from"react";import{createContext as he}from"react";var I=he();var N=()=>le(I);import re,{useEffect as Fe,useRef as Ne,useState as U}from"react";import*as R from"react";var ue=Object.defineProperty,de=Object.defineProperties,pe=Object.getOwnPropertyDescriptors,A=Object.getOwnPropertySymbols,J=Object.prototype.hasOwnProperty,K=Object.prototype.propertyIsEnumerable,q=(t,e,n)=>e in t?ue(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,g=(t,e)=>{for(var n in e||(e={}))J.call(e,n)&&q(t,n,e[n]);if(A)for(var n of A(e))K.call(e,n)&&q(t,n,e[n]);return t},G=(t,e)=>de(t,pe(e)),fe=(t,e)=>{var n={};for(var r in t)J.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&A)for(var r of A(t))e.indexOf(r)<0&&K.call(t,r)&&(n[r]=t[r]);return n},l=(t,e,n)=>(q(t,typeof e!="symbol"?e+"":e,n),n),C=(t,e,n)=>new Promise((r,i)=>{var a=s=>{try{h(n.next(s))}catch(c){i(c)}},o=s=>{try{h(n.throw(s))}catch(c){i(c)}},h=s=>s.done?r(s.value):Promise.resolve(s.value).then(a,o);h((n=n.apply(t,e)).next())}),me="hCaptcha-script",j="hCaptchaOnLoad",W="script-error",b="@hCaptcha/loader";function ge(t){return Object.entries(t).filter(([,e])=>e||e===!1).map(([e,n])=>`${encodeURIComponent(e)}=${encodeURIComponent(String(n))}`).join("&")}function X(t){let e=t&&t.ownerDocument||document,n=e.defaultView||e.parentWindow||window;return{document:e,window:n}}function Q(t){return t||document.head}function ye(t){var e;t.setTag("source",b),t.setTag("url",document.URL),t.setContext("os",{UA:navigator.userAgent}),t.setContext("browser",g({},ve())),t.setContext("device",G(g({},be()),{screen_width_pixels:screen.width,screen_height_pixels:screen.height,language:navigator.language,orientation:((e=screen.orientation)==null?void 0:e.type)||"Unknown",processor_count:navigator.hardwareConcurrency,platform:navigator.platform}))}function ve(){var t,e,n,r,i,a;let o=navigator.userAgent,h,s;return o.indexOf("Firefox")!==-1?(h="Firefox",s=(t=o.match(/Firefox\/([\d.]+)/))==null?void 0:t[1]):o.indexOf("Edg")!==-1?(h="Microsoft Edge",s=(e=o.match(/Edg\/([\d.]+)/))==null?void 0:e[1]):o.indexOf("Chrome")!==-1&&o.indexOf("Safari")!==-1?(h="Chrome",s=(n=o.match(/Chrome\/([\d.]+)/))==null?void 0:n[1]):o.indexOf("Safari")!==-1&&o.indexOf("Chrome")===-1?(h="Safari",s=(r=o.match(/Version\/([\d.]+)/))==null?void 0:r[1]):o.indexOf("Opera")!==-1||o.indexOf("OPR")!==-1?(h="Opera",s=(i=o.match(/(Opera|OPR)\/([\d.]+)/))==null?void 0:i[2]):o.indexOf("MSIE")!==-1||o.indexOf("Trident")!==-1?(h="Internet Explorer",s=(a=o.match(/(MSIE |rv:)([\d.]+)/))==null?void 0:a[2]):(h="Unknown",s="Unknown"),{name:h,version:s}}function xe(t){return new Promise(e=>setTimeout(e,t))}function be(){let t=navigator.userAgent,e;t.indexOf("Win")!==-1?e="Windows":t.indexOf("Mac")!==-1?e="Mac":t.indexOf("Linux")!==-1?e="Linux":t.indexOf("Android")!==-1?e="Android":t.indexOf("like Mac")!==-1||t.indexOf("iPhone")!==-1||t.indexOf("iPad")!==-1?e="iOS":e="Unknown";let n;return/Mobile|iPhone|iPod|Android/i.test(t)?n="Mobile":/Tablet|iPad/i.test(t)?n="Tablet":n="Desktop",{model:e,family:e,device:n}}var we=class Y{constructor(e){l(this,"_parent"),l(this,"breadcrumbs",[]),l(this,"context",{}),l(this,"extra",{}),l(this,"tags",{}),l(this,"request"),l(this,"user"),this._parent=e}get parent(){return this._parent}child(){return new Y(this)}setRequest(e){return this.request=e,this}removeRequest(){return this.request=void 0,this}addBreadcrumb(e){return typeof e.timestamp>"u"&&(e.timestamp=new Date().toISOString()),this.breadcrumbs.push(e),this}setExtra(e,n){return this.extra[e]=n,this}removeExtra(e){return delete this.extra[e],this}setContext(e,n){return typeof n.type>"u"&&(n.type=e),this.context[e]=n,this}removeContext(e){return delete this.context[e],this}setTags(e){return this.tags=g(g({},this.tags),e),this}setTag(e,n){return this.tags[e]=n,this}removeTag(e){return delete this.tags[e],this}setUser(e){return this.user=e,this}removeUser(){return this.user=void 0,this}toBody(){let e=[],n=this;for(;n;)e.push(n),n=n.parent;return e.reverse().reduce((r,i)=>{var a;return r.breadcrumbs=[...(a=r.breadcrumbs)!=null?a:[],...i.breadcrumbs],r.extra=g(g({},r.extra),i.extra),r.contexts=g(g({},r.contexts),i.context),r.tags=g(g({},r.tags),i.tags),i.user&&(r.user=i.user),i.request&&(r.request=i.request),r},{breadcrumbs:[],extra:{},contexts:{},tags:{},request:void 0,user:void 0})}clear(){this.breadcrumbs=[],this.context={},this.tags={},this.user=void 0}},Ee=/^\s*at (?:(.*?) ?\()?((?:file|https?|blob|chrome-extension|address|native|eval|webpack|<anonymous>|[-a-z]+:|.*bundle|\/).*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,Ce=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:file|https?|blob|chrome|webpack|resource|moz-extension).*?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js))(?::(\d+))?(?::(\d+))?\s*$/i,Re=/^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|webpack|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i,_e=/^(?:(\w+):)\/\/(?:(\w+)(?::(\w+))?@)([\w.-]+)(?::(\d+))?\/(.+)/,S="?",z="An unknown error occurred",Oe="0.0.4";function Pe(t){for(let e=0;e<t.length;e++)t[e]=Math.floor(Math.random()*256);return t}function p(t){return(t+256).toString(16).substring(1)}function Ie(){let t=Pe(new Array(16));return t[6]=t[6]&15|64,t[8]=t[8]&63|128,p(t[0])+p(t[1])+p(t[2])+p(t[3])+"-"+p(t[4])+p(t[5])+"-"+p(t[6])+p(t[7])+"-"+p(t[8])+p(t[9])+"-"+p(t[10])+p(t[11])+p(t[12])+p(t[13])+p(t[14])+p(t[15])}var Se=[[Ee,"chrome"],[Re,"winjs"],[Ce,"gecko"]];function ke(t){var e,n,r,i;if(!t.stack)return null;let a=[],o=(r=(n=(e=t.stack).split)==null?void 0:n.call(e,`
2
+ `))!=null?r:[];for(let h=0;h<o.length;++h){let s=null,c=null,u=null;for(let[y,v]of Se)if(c=y.exec(o[h]),c){u=v;break}if(!(!c||!u)){if(u==="chrome")s={filename:(i=c[2])!=null&&i.startsWith("address at ")?c[2].substring(11):c[2],function:c[1]||S,lineno:c[3]?+c[3]:null,colno:c[4]?+c[4]:null};else if(u==="winjs")s={filename:c[2],function:c[1]||S,lineno:+c[3],colno:c[4]?+c[4]:null};else if(u==="gecko")h===0&&!c[5]&&t.columnNumber!==void 0&&a.length>0&&(a[0].column=t.columnNumber+1),s={filename:c[3],function:c[1]||S,lineno:c[4]?+c[4]:null,colno:c[5]?+c[5]:null};else continue;!s.function&&s.lineno&&(s.function=S),a.push(s)}}return a.length?a.reverse():null}function je(t){let e=ke(t);return{type:t.name,value:t.message,stacktrace:{frames:e!=null?e:[]}}}function Ae(t){let e=_e.exec(t),n=e?e.slice(1):[];if(n.length!==6)throw new Error("Invalid DSN");let r=n[5].split("/"),i=r.slice(0,-1).join("/");return n[0]+"://"+n[3]+(n[4]?":"+n[4]:"")+(i?"/"+i:"")+"/api/"+r.pop()+"/envelope/?sentry_version=7&sentry_key="+n[1]+(n[2]?"&sentry_secret="+n[2]:"")}function qe(t,e,n){var r,i;let a=g({event_id:Ie().replaceAll("-",""),platform:"javascript",sdk:{name:"@hcaptcha/sentry",version:Oe},environment:e,release:n,timestamp:Date.now()/1e3},t.scope.toBody());if(t.type==="exception"){a.message=(i=(r=t.error)==null?void 0:r.message)!=null?i:"Unknown error",a.fingerprint=[a.message];let o=[],h=t.error;for(let s=0;s<5&&h&&(o.push(je(h)),!(!h.cause||!(h.cause instanceof Error)));s++)h=h.cause;a.exception={values:o.reverse()}}return t.type==="message"&&(a.message=t.message,a.level=t.level),a}function Le(t){if(t instanceof Error)return t;if(typeof t=="string")return new Error(t);if(typeof t=="object"&&t!==null&&!Array.isArray(t)){let n=t,{message:r}=n,i=fe(n,["message"]),a=new Error(typeof r=="string"?r:z);return Object.assign(a,i)}let e=new Error(z);return Object.assign(e,{cause:t})}function Me(t,e,n){return C(this,null,function*(){var r,i;try{if(typeof fetch<"u"&&typeof AbortSignal<"u"){let a;if(n){let s=new AbortController;a=s.signal,setTimeout(()=>s.abort(),n)}let o=yield fetch(t,G(g({},e),{signal:a})),h=yield o.text();return{status:o.status,body:h}}return yield new Promise((a,o)=>{var h,s;let c=new XMLHttpRequest;if(c.open((h=e==null?void 0:e.method)!=null?h:"GET",t),c.onload=()=>a({status:c.status,body:c.responseText}),c.onerror=()=>o(new Error("XHR Network Error")),e==null?void 0:e.headers)for(let[u,y]of Object.entries(e.headers))c.setRequestHeader(u,y);if(n){let u=setTimeout(()=>{c.abort(),o(new Error("Request timed out"))},n);c.onloadend=()=>{clearTimeout(u)}}c.send((s=e==null?void 0:e.body)==null?void 0:s.toString())})}catch(a){return{status:0,body:(i=(r=a==null?void 0:a.toString)==null?void 0:r.call(a))!=null?i:"Unknown error"}}})}var m,L=(m=class{constructor(t){l(this,"apiURL"),l(this,"dsn"),l(this,"environment"),l(this,"release"),l(this,"sampleRate"),l(this,"debug"),l(this,"_scope"),l(this,"shouldBuffer",!1),l(this,"bufferlimit",20),l(this,"buffer",[]);var e,n,r,i,a;this.environment=t.environment,this.release=t.release,this.sampleRate=(e=t.sampleRate)!=null?e:1,this.debug=(n=t.debug)!=null?n:!1,this._scope=(r=t.scope)!=null?r:new we,this.apiURL=Ae(t.dsn),this.dsn=t.dsn,this.shouldBuffer=(i=t.buffer)!=null?i:!1,this.bufferlimit=(a=t.bufferLimit)!=null?a:20}static init(t){m._instance||(m._instance=new m(t))}static get instance(){if(!m._instance)throw new Error("Sentry has not been initialized");return m._instance}log(...t){this.debug&&console.log(...t)}get scope(){return this._scope}static get scope(){return m.instance.scope}withScope(t){let e=this._scope.child();t(e)}static withScope(t){m.instance.withScope(t)}captureException(t,e){this.captureEvent({type:"exception",level:"error",error:Le(t),scope:e!=null?e:this._scope})}static captureException(t,e){m.instance.captureException(t,e)}captureMessage(t,e="info",n){this.captureEvent({type:"message",level:e,message:t,scope:n!=null?n:this._scope})}static captureMessage(t,e="info",n){m.instance.captureMessage(t,e,n)}captureEvent(t){if(Math.random()>=this.sampleRate){this.log("Dropped event due to sample rate");return}if(this.shouldBuffer){if(this.buffer.length>=this.bufferlimit)return;this.buffer.push(t)}else this.sendEvent(t)}sendEvent(t,e=5e3){return C(this,null,function*(){try{this.log("Sending sentry event",t);let n=qe(t,this.environment,this.release),r={event_id:n.event_id,dsn:this.dsn},i={type:"event"},a=JSON.stringify(r)+`
3
3
  `+JSON.stringify(i)+`
4
- `+JSON.stringify(n),o=yield Me(this.apiURL,{method:"POST",headers:{"Content-Type":"application/x-sentry-envelope"},body:a},e);this.log("Sentry response",o.status),o.status!==200&&(console.log(o.body),console.error("Failed to send event to Sentry",o))}catch(n){console.error("Failed to send event",n)}})}flush(t=5e3){return C(this,null,function*(){try{this.log("Flushing sentry events",this.buffer.length);let e=this.buffer.splice(0,this.buffer.length).map(n=>this.sendEvent(n,t));yield Promise.all(e),this.log("Flushed all events")}catch(e){console.error("Failed to flush events",e)}})}static flush(t=5e3){return m.instance.flush(t)}static reset(){m._instance=void 0}},l(m,"_instance"),m),Te="https://d233059272824702afc8c43834c4912d@sentry.hcaptcha.com/6",Ue="2.3.0",He="production";function Be(t=!0){if(!t)return V();L.init({dsn:Te,release:Ue,environment:He});let e=L.scope;return ye(e),V(e)}function V(t=null){return{addBreadcrumb:e=>{t&&t.addBreadcrumb(e)},captureRequest:e=>{t&&t.setRequest(e)},captureException:e=>{t&&L.captureException(e,t)}}}function De({scriptLocation:t,query:e,loadAsync:n=!0,crossOrigin:r="anonymous",apihost:i="https://js.hcaptcha.com",cleanup:a=!1,secureApi:o=!1,scriptSource:h=""}={},s){let c=Q(t),u=X(c);return new Promise((y,v)=>{let d=u.document.createElement("script");d.id=me,h?d.src=`${h}?onload=${j}`:o?d.src=`${i}/1/secure-api.js?onload=${j}`:d.src=`${i}/1/api.js?onload=${j}`,d.crossOrigin=r,d.async=n;let w=(x,E)=>{try{!o&&a&&c.removeChild(d),E(x)}catch(P){v(P)}};d.onload=x=>w(x,y),d.onerror=x=>{s&&s(d.src),w(x,v)},d.src+=e!==""?`&${e}`:"",c.appendChild(d)})}var k=[];function $e(t={cleanup:!1},e){try{e.addBreadcrumb({category:b,message:"hCaptcha loader params",data:t});let n=Q(t.scriptLocation),r=X(n),i=k.find(({scope:o})=>o===r.window);if(i)return e.addBreadcrumb({category:b,message:"hCaptcha already loaded"}),i.promise;let a=new Promise((o,h)=>C(this,null,function*(){try{r.window[j]=()=>{e.addBreadcrumb({category:b,message:"hCaptcha script called onload function"}),o(r.window.hcaptcha)};let s=ge({custom:t.custom,render:t.render,sentry:t.sentry,assethost:t.assethost,imghost:t.imghost,reportapi:t.reportapi,endpoint:t.endpoint,host:t.host,recaptchacompat:t.recaptchacompat,hl:t.hl,uj:t.uj});yield De(g({query:s},t),c=>{e.captureRequest({url:c,method:"GET"})}),e.addBreadcrumb({category:b,message:"hCaptcha loaded",data:i})}catch(s){e.addBreadcrumb({category:b,message:"hCaptcha failed to load"});let c=k.findIndex(u=>u.scope===r.window);c!==-1&&k.splice(c,1),h(new Error(W))}}));return k.push({promise:a,scope:r.window}),a}catch(n){return e.captureException(n),Promise.reject(new Error(W))}}function Z(t,e,n=0){return C(this,null,function*(){var r,i;let a=(r=t.maxRetries)!=null?r:2,o=(i=t.retryDelay)!=null?i:1e3,h=n<a?"Retry loading hCaptcha Api":"Exceeded maximum retries";try{return yield $e(t,e)}catch(s){return e.addBreadcrumb({category:b,message:h}),n>=a?(e.captureException(s),Promise.reject(s)):(e.addBreadcrumb({category:b,message:`Waiting ${o}ms before retry attempt ${n+1}`}),yield xe(o),n+=1,Z(t,e,n))}})}function ee(){return C(this,arguments,function*(t={}){let e=Be(t.sentry);return yield Z(t,e)})}function M(t){let e=t&&t.ownerDocument||document,n=e.defaultView||e.parentWindow||window;return{document:e,window:n}}function T(t){return t||document.head}var O=class extends R.Component{constructor(e){super(e),this._hcaptcha=void 0,this.renderCaptcha=this.renderCaptcha.bind(this),this.resetCaptcha=this.resetCaptcha.bind(this),this.removeCaptcha=this.removeCaptcha.bind(this),this.isReady=this.isReady.bind(this),this._onReady=null,this.loadCaptcha=this.loadCaptcha.bind(this),this.handleOnLoad=this.handleOnLoad.bind(this),this.handleSubmit=this.handleSubmit.bind(this),this.handleExpire=this.handleExpire.bind(this),this.handleError=this.handleError.bind(this),this.handleOpen=this.handleOpen.bind(this),this.handleClose=this.handleClose.bind(this),this.handleChallengeExpired=this.handleChallengeExpired.bind(this),this.ref=R.createRef(),this.apiScriptRequested=!1,this.sentryHub=null,this.captchaId="",this._pendingExecute=null,this.state={isApiReady:!1,isRemoved:!1,elementId:e.id}}componentDidMount(){let e=T(this.props.scriptLocation),n=M(e);if(this._hcaptcha=n.window.hcaptcha||void 0,typeof this._hcaptcha!="undefined"){this.setState({isApiReady:!0},()=>{this.renderCaptcha()});return}this.loadCaptcha()}componentWillUnmount(){let e=this._hcaptcha,n=this.captchaId;this._cancelPendingExecute("react-component-unmounted"),this.isReady()&&(e.reset(n),e.remove(n))}shouldComponentUpdate(e,n){return!(this.state.isApiReady!==n.isApiReady||this.state.isRemoved!==n.isRemoved)}componentDidUpdate(e){["sitekey","size","theme","tabindex","languageOverride","endpoint"].every(i=>e[i]===this.props[i])||this.removeCaptcha(()=>{this.renderCaptcha()})}loadCaptcha(){if(this.apiScriptRequested)return;let{apihost:e,assethost:n,endpoint:r,host:i,imghost:a,languageOverride:o,reCaptchaCompat:h,reportapi:s,sentry:c,custom:u,loadAsync:y,scriptLocation:v,scriptSource:d,secureApi:w,cleanup:x=!0,userJourneys:E}=this.props;ee({render:"explicit",apihost:e,assethost:n,endpoint:r,hl:o,host:i,imghost:a,recaptchacompat:h===!1?"off":null,reportapi:s,sentry:c,custom:u,loadAsync:y,scriptLocation:v,scriptSource:d,secureApi:w,cleanup:x,uj:E!==void 0?E:!1}).then(this.handleOnLoad,this.handleError).catch(this.handleError),this.apiScriptRequested=!0}renderCaptcha(e){let{onReady:n}=this.props,{isApiReady:r}=this.state,i=this.captchaId;if(!r||i)return;let a=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}),h=this._hcaptcha.render(this.ref.current,a);this.captchaId=h,this.setState({isRemoved:!1},()=>{e&&e(),n&&n(),this._onReady&&this._onReady(h)})}resetCaptcha(){let e=this._hcaptcha,n=this.captchaId;this.isReady()&&(e.reset(n),this._cancelPendingExecute("hcaptcha-reset"))}removeCaptcha(e){let n=this._hcaptcha,r=this.captchaId;this._cancelPendingExecute("hcaptcha-removed"),this.isReady()&&this.setState({isRemoved:!0},()=>{this.captchaId="",n.remove(r),e&&e()})}handleOnLoad(){this.setState({isApiReady:!0},()=>{let e=T(this.props.scriptLocation),n=M(e);this._hcaptcha=n.window.hcaptcha,this.renderCaptcha(()=>{let{onLoad:r}=this.props;r&&r()})})}handleSubmit(e){let{onVerify:n}=this.props,{isRemoved:r}=this.state,i=this._hcaptcha,a=this.captchaId;if(typeof i=="undefined"||r)return;let o=i.getResponse(a),h=i.getRespKey(a);n&&n(o,h)}handleExpire(){let{onExpire:e}=this.props,n=this._hcaptcha,r=this.captchaId;this.isReady()&&(n.reset(r),e&&e())}handleError(e){let{onError:n}=this.props,r=this._hcaptcha,i=this.captchaId;this.isReady()&&r.reset(i),n&&n(e)}isReady(){let{isApiReady:e,isRemoved:n}=this.state;return e&&!n}_cancelPendingExecute(e){if(!this._pendingExecute)return;let n=this._pendingExecute;this._pendingExecute=null;let r=new Error(e);n.reject(r)}handleOpen(){!this.isReady()||!this.props.onOpen||this.props.onOpen()}handleClose(){!this.isReady()||!this.props.onClose||this.props.onClose()}handleChallengeExpired(){!this.isReady()||!this.props.onChalExpired||this.props.onChalExpired()}execute(e=null){e=typeof e=="object"?e:null;try{let n=this._hcaptcha,r=this.captchaId;if(e&&e.async&&this._pendingExecute&&this._cancelPendingExecute("hcaptcha-execute-replaced"),!this.isReady())return e&&e.async?new Promise((a,o)=>{this._pendingExecute={resolve:a,reject:o},this._onReady=h=>{if(this._pendingExecute)try{let s=n.execute(h,e);s&&typeof s.then=="function"?s.then(c=>{this._pendingExecute=null,a(c)}).catch(c=>{this._pendingExecute=null,o(c)}):(this._pendingExecute=null,o(new Error("hcaptcha-execute-no-promise")))}catch(s){this._pendingExecute=null,o(s)}}}):(this._onReady=a=>{n.execute(a,e)},null);let i=n.execute(r,e);return e&&e.async&&i&&typeof i.then=="function"?new Promise((a,o)=>{this._pendingExecute={resolve:a,reject:o},i.then(h=>{this._pendingExecute=null,a(h)}).catch(h=>{this._pendingExecute=null,o(h)})}):i}catch(n){return e&&e.async?Promise.reject(n):null}}close(){let e=this._hcaptcha,n=this.captchaId;if(this._cancelPendingExecute("hcaptcha-closed"),!!this.isReady())return e.close(n)}setData(e){let n=this._hcaptcha,r=this.captchaId;this.isReady()&&(e&&typeof e!="object"&&(e=null),n.setData(r,e))}getResponse(){return this._hcaptcha.getResponse(this.captchaId)}getRespKey(){return this._hcaptcha.getRespKey(this.captchaId)}render(){let{elementId:e}=this.state;return R.createElement("div",{ref:this.ref,id:e})}};var te=O;function ne({sitekey:t=null,size:e="normal",theme:n="light",rqdata:r=null,languageOverride:i=null,onVerify:a,onError:o,children:h}){let s=Ne(null),[c,u]=U(!1),[y,v]=U(null),[d,w]=U(null),x=()=>{u(!0)},E=f=>{w(f),o&&o(f)},P=()=>{v(null)},se=f=>{v(f),a&&a(f)},ie=(...mt)=>F(this,[...mt],function*(f={}){try{if(!c)throw new Error("hCaptcha not ready");y&&H();let{response:_}=yield s.current.execute($({async:!0},f.rqdata?{rqdata:f.rqdata}:{}));return v(_),_}catch(_){w(_),o&&o(_)}}),H=()=>{var f;(f=s==null?void 0:s.current)==null||f.resetCaptcha()};return Fe(()=>{var f;r&&((f=s==null?void 0:s.current)==null||f.setData(r))},[r]),re.createElement(S.Provider,{value:{sitekey:t,error:d,token:y,ready:c,executeInstance:ie,resetInstance:H}},h,re.createElement(te,{sitekey:t,size:e,theme:n,languageOverride:i,onReady:x,onVerify:se,onExpire:P,onError:E,ref:s}))}export{ne as HCaptchaProvider,N as useHCaptcha};
4
+ `+JSON.stringify(n),o=yield Me(this.apiURL,{method:"POST",headers:{"Content-Type":"application/x-sentry-envelope"},body:a},e);this.log("Sentry response",o.status),o.status!==200&&(console.log(o.body),console.error("Failed to send event to Sentry",o))}catch(n){console.error("Failed to send event",n)}})}flush(t=5e3){return C(this,null,function*(){try{this.log("Flushing sentry events",this.buffer.length);let e=this.buffer.splice(0,this.buffer.length).map(n=>this.sendEvent(n,t));yield Promise.all(e),this.log("Flushed all events")}catch(e){console.error("Failed to flush events",e)}})}static flush(t=5e3){return m.instance.flush(t)}static reset(){m._instance=void 0}},l(m,"_instance"),m),Te="https://d233059272824702afc8c43834c4912d@sentry.hcaptcha.com/6",Ue="2.3.0",He="production";function Be(t=!0){if(!t)return V();L.init({dsn:Te,release:Ue,environment:He});let e=L.scope;return ye(e),V(e)}function V(t=null){return{addBreadcrumb:e=>{t&&t.addBreadcrumb(e)},captureRequest:e=>{t&&t.setRequest(e)},captureException:e=>{t&&L.captureException(e,t)}}}function De({scriptLocation:t,query:e,loadAsync:n=!0,crossOrigin:r="anonymous",apihost:i="https://js.hcaptcha.com",cleanup:a=!1,secureApi:o=!1,scriptSource:h=""}={},s){let c=Q(t),u=X(c);return new Promise((y,v)=>{let d=u.document.createElement("script");d.id=me,h?d.src=`${h}?onload=${j}`:o?d.src=`${i}/1/secure-api.js?onload=${j}`:d.src=`${i}/1/api.js?onload=${j}`,d.crossOrigin=r,d.async=n;let w=(x,E)=>{try{!o&&a&&c.removeChild(d),E(x)}catch(P){v(P)}};d.onload=x=>w(x,y),d.onerror=x=>{s&&s(d.src),w(x,v)},d.src+=e!==""?`&${e}`:"",c.appendChild(d)})}var k=[];function $e(t={cleanup:!1},e){try{e.addBreadcrumb({category:b,message:"hCaptcha loader params",data:t});let n=Q(t.scriptLocation),r=X(n),i=k.find(({scope:o})=>o===r.window);if(i)return e.addBreadcrumb({category:b,message:"hCaptcha already loaded"}),i.promise;let a=new Promise((o,h)=>C(this,null,function*(){try{r.window[j]=()=>{e.addBreadcrumb({category:b,message:"hCaptcha script called onload function"}),o(r.window.hcaptcha)};let s=ge({custom:t.custom,render:t.render,sentry:t.sentry,assethost:t.assethost,imghost:t.imghost,reportapi:t.reportapi,endpoint:t.endpoint,host:t.host,recaptchacompat:t.recaptchacompat,hl:t.hl,uj:t.uj});yield De(g({query:s},t),c=>{e.captureRequest({url:c,method:"GET"})}),e.addBreadcrumb({category:b,message:"hCaptcha loaded",data:i})}catch(s){e.addBreadcrumb({category:b,message:"hCaptcha failed to load"});let c=k.findIndex(u=>u.scope===r.window);c!==-1&&k.splice(c,1),h(new Error(W))}}));return k.push({promise:a,scope:r.window}),a}catch(n){return e.captureException(n),Promise.reject(new Error(W))}}function Z(t,e,n=0){return C(this,null,function*(){var r,i;let a=(r=t.maxRetries)!=null?r:2,o=(i=t.retryDelay)!=null?i:1e3,h=n<a?"Retry loading hCaptcha Api":"Exceeded maximum retries";try{return yield $e(t,e)}catch(s){return e.addBreadcrumb({category:b,message:h}),n>=a?(e.captureException(s),Promise.reject(s)):(e.addBreadcrumb({category:b,message:`Waiting ${o}ms before retry attempt ${n+1}`}),yield xe(o),n+=1,Z(t,e,n))}})}function ee(){return C(this,arguments,function*(t={}){let e=Be(t.sentry);return yield Z(t,e)})}function M(t){let e=t&&t.ownerDocument||document,n=e.defaultView||e.parentWindow||window;return{document:e,window:n}}function T(t){return t||document.head}var O=class extends R.Component{constructor(e){super(e),this._hcaptcha=void 0,this.renderCaptcha=this.renderCaptcha.bind(this),this.resetCaptcha=this.resetCaptcha.bind(this),this.removeCaptcha=this.removeCaptcha.bind(this),this.isReady=this.isReady.bind(this),this._onReady=null,this.loadCaptcha=this.loadCaptcha.bind(this),this.handleOnLoad=this.handleOnLoad.bind(this),this.handleSubmit=this.handleSubmit.bind(this),this.handleExpire=this.handleExpire.bind(this),this.handleError=this.handleError.bind(this),this.handleOpen=this.handleOpen.bind(this),this.handleClose=this.handleClose.bind(this),this.handleChallengeExpired=this.handleChallengeExpired.bind(this),this.ref=R.createRef(),this.apiScriptRequested=!1,this.sentryHub=null,this.captchaId="",this._pendingExecute=null,this.state={isApiReady:!1,isRemoved:!1,elementId:e.id}}componentDidMount(){let e=T(this.props.scriptLocation),n=M(e);if(this._hcaptcha=n.window.hcaptcha||void 0,typeof this._hcaptcha!="undefined"){this.setState({isApiReady:!0},()=>{this.renderCaptcha()});return}this.loadCaptcha()}componentWillUnmount(){let e=this._hcaptcha,n=this.captchaId;if(this._cancelPendingExecute("react-component-unmounted"),!!this.isReady())try{e.reset(n),e.remove(n)}catch(r){}finally{this.captchaId="",this._onReady=null}}shouldComponentUpdate(e,n){return!(this.state.isApiReady!==n.isApiReady||this.state.isRemoved!==n.isRemoved)}componentDidUpdate(e){["sitekey","size","theme","tabindex","languageOverride","endpoint"].every(i=>e[i]===this.props[i])||this.removeCaptcha(()=>{this.renderCaptcha()})}loadCaptcha(){if(this.apiScriptRequested)return;let{apihost:e,assethost:n,endpoint:r,host:i,imghost:a,languageOverride:o,reCaptchaCompat:h,reportapi:s,sentry:c,custom:u,loadAsync:y,scriptLocation:v,scriptSource:d,secureApi:w,cleanup:x=!0,userJourneys:E}=this.props;ee({render:"explicit",apihost:e,assethost:n,endpoint:r,hl:o,host:i,imghost:a,recaptchacompat:h===!1?"off":null,reportapi:s,sentry:c,custom:u,loadAsync:y,scriptLocation:v,scriptSource:d,secureApi:w,cleanup:x,uj:E!==void 0?E:!1}).then(this.handleOnLoad,this.handleError).catch(this.handleError),this.apiScriptRequested=!0}renderCaptcha(e){let{onReady:n}=this.props,{isApiReady:r}=this.state,i=this.captchaId;if(!r||i)return;let a=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}),h=this._hcaptcha.render(this.ref.current,a);this.captchaId=h,this.setState({isRemoved:!1},()=>{e&&e(),n&&n(),this._onReady&&this._onReady(h)})}resetCaptcha(){let e=this._hcaptcha,n=this.captchaId;this.isReady()&&(e.reset(n),this._cancelPendingExecute("hcaptcha-reset"))}removeCaptcha(e){let n=this._hcaptcha,r=this.captchaId;this._cancelPendingExecute("hcaptcha-removed"),this.isReady()&&this.setState({isRemoved:!0},()=>{this.captchaId="",n.remove(r),e&&e()})}handleOnLoad(){this.setState({isApiReady:!0},()=>{let e=T(this.props.scriptLocation),n=M(e);this._hcaptcha=n.window.hcaptcha,this.renderCaptcha(()=>{let{onLoad:r}=this.props;r&&r()})})}handleSubmit(e){let{onVerify:n}=this.props,{isRemoved:r}=this.state,i=this._hcaptcha,a=this.captchaId;if(typeof i=="undefined"||r)return;let o=i.getResponse(a),h=i.getRespKey(a);n&&n(o,h)}handleExpire(){let{onExpire:e}=this.props,n=this._hcaptcha,r=this.captchaId;this.isReady()&&(n.reset(r),e&&e())}handleError(e){let{onError:n}=this.props,r=this._hcaptcha,i=this.captchaId;this.isReady()&&r.reset(i),n&&n(e)}isReady(){let{isApiReady:e,isRemoved:n}=this.state;return e&&!n}_cancelPendingExecute(e){if(!this._pendingExecute)return;let n=this._pendingExecute;this._pendingExecute=null;let r=new Error(e);n.reject(r)}handleOpen(){!this.isReady()||!this.props.onOpen||this.props.onOpen()}handleClose(){!this.isReady()||!this.props.onClose||this.props.onClose()}handleChallengeExpired(){!this.isReady()||!this.props.onChalExpired||this.props.onChalExpired()}execute(e=null){e=typeof e=="object"?e:null;try{let n=this._hcaptcha,r=this.captchaId;if(e&&e.async&&this._pendingExecute&&this._cancelPendingExecute("hcaptcha-execute-replaced"),!this.isReady())return e&&e.async?new Promise((a,o)=>{this._pendingExecute={resolve:a,reject:o},this._onReady=h=>{if(this._pendingExecute)try{let s=n.execute(h,e);s&&typeof s.then=="function"?s.then(c=>{this._pendingExecute=null,a(c)}).catch(c=>{this._pendingExecute=null,o(c)}):(this._pendingExecute=null,o(new Error("hcaptcha-execute-no-promise")))}catch(s){this._pendingExecute=null,o(s)}}}):(this._onReady=a=>{n.execute(a,e)},null);let i=n.execute(r,e);return e&&e.async&&i&&typeof i.then=="function"?new Promise((a,o)=>{this._pendingExecute={resolve:a,reject:o},i.then(h=>{this._pendingExecute=null,a(h)}).catch(h=>{this._pendingExecute=null,o(h)})}):i}catch(n){return e&&e.async?Promise.reject(n):null}}close(){let e=this._hcaptcha,n=this.captchaId;if(this._cancelPendingExecute("hcaptcha-closed"),!!this.isReady())return e.close(n)}setData(e){let n=this._hcaptcha,r=this.captchaId;this.isReady()&&(e&&typeof e!="object"&&(e=null),n.setData(r,e))}getResponse(){return this._hcaptcha.getResponse(this.captchaId)}getRespKey(){return this._hcaptcha.getRespKey(this.captchaId)}render(){let{elementId:e}=this.state;return R.createElement("div",{ref:this.ref,id:e})}};var te=O;function ne({sitekey:t=null,size:e="normal",theme:n="light",rqdata:r=null,languageOverride:i=null,onVerify:a,onError:o,children:h}){let s=Ne(null),[c,u]=U(!1),[y,v]=U(null),[d,w]=U(null),x=()=>{u(!0)},E=f=>{w(f),o&&o(f)},P=()=>{v(null)},se=f=>{v(f),a&&a(f)},ie=(...mt)=>F(this,[...mt],function*(f={}){try{if(!c)throw new Error("hCaptcha not ready");y&&H();let{response:_}=yield s.current.execute($({async:!0},f.rqdata?{rqdata:f.rqdata}:{}));return v(_),_}catch(_){w(_),o&&o(_)}}),H=()=>{var f;(f=s==null?void 0:s.current)==null||f.resetCaptcha()};return Fe(()=>{var f;r&&((f=s==null?void 0:s.current)==null||f.setData(r))},[r]),re.createElement(I.Provider,{value:{sitekey:t,error:d,token:y,ready:c,executeInstance:ie,resetInstance:H}},h,re.createElement(te,{sitekey:t,size:e,theme:n,languageOverride:i,onReady:x,onVerify:se,onExpire:P,onError:E,ref:s}))}export{ne as HCaptchaProvider,N as useHCaptcha};
@@ -1,4 +1,4 @@
1
- var ae=Object.defineProperty;var B=Object.getOwnPropertySymbols;var oe=Object.prototype.hasOwnProperty,ce=Object.prototype.propertyIsEnumerable;var D=(t,e,n)=>e in t?ae(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,$=(t,e)=>{for(var n in e||(e={}))oe.call(e,n)&&D(t,n,e[n]);if(B)for(var n of B(e))ce.call(e,n)&&D(t,n,e[n]);return t};var F=(t,e,n)=>new Promise((r,i)=>{var a=s=>{try{h(n.next(s))}catch(c){i(c)}},o=s=>{try{h(n.throw(s))}catch(c){i(c)}},h=s=>s.done?r(s.value):Promise.resolve(s.value).then(a,o);h((n=n.apply(t,e)).next())});import*as R from"react";var he=Object.defineProperty,le=Object.defineProperties,ue=Object.getOwnPropertyDescriptors,j=Object.getOwnPropertySymbols,V=Object.prototype.hasOwnProperty,J=Object.prototype.propertyIsEnumerable,q=(t,e,n)=>e in t?he(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,g=(t,e)=>{for(var n in e||(e={}))V.call(e,n)&&q(t,n,e[n]);if(j)for(var n of j(e))J.call(e,n)&&q(t,n,e[n]);return t},K=(t,e)=>le(t,ue(e)),de=(t,e)=>{var n={};for(var r in t)V.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&j)for(var r of j(t))e.indexOf(r)<0&&J.call(t,r)&&(n[r]=t[r]);return n},l=(t,e,n)=>(q(t,typeof e!="symbol"?e+"":e,n),n),C=(t,e,n)=>new Promise((r,i)=>{var a=s=>{try{h(n.next(s))}catch(c){i(c)}},o=s=>{try{h(n.throw(s))}catch(c){i(c)}},h=s=>s.done?r(s.value):Promise.resolve(s.value).then(a,o);h((n=n.apply(t,e)).next())}),pe="hCaptcha-script",k="hCaptchaOnLoad",N="script-error",b="@hCaptcha/loader";function fe(t){return Object.entries(t).filter(([,e])=>e||e===!1).map(([e,n])=>`${encodeURIComponent(e)}=${encodeURIComponent(String(n))}`).join("&")}function G(t){let e=t&&t.ownerDocument||document,n=e.defaultView||e.parentWindow||window;return{document:e,window:n}}function X(t){return t||document.head}function me(t){var e;t.setTag("source",b),t.setTag("url",document.URL),t.setContext("os",{UA:navigator.userAgent}),t.setContext("browser",g({},ge())),t.setContext("device",K(g({},ve()),{screen_width_pixels:screen.width,screen_height_pixels:screen.height,language:navigator.language,orientation:((e=screen.orientation)==null?void 0:e.type)||"Unknown",processor_count:navigator.hardwareConcurrency,platform:navigator.platform}))}function ge(){var t,e,n,r,i,a;let o=navigator.userAgent,h,s;return o.indexOf("Firefox")!==-1?(h="Firefox",s=(t=o.match(/Firefox\/([\d.]+)/))==null?void 0:t[1]):o.indexOf("Edg")!==-1?(h="Microsoft Edge",s=(e=o.match(/Edg\/([\d.]+)/))==null?void 0:e[1]):o.indexOf("Chrome")!==-1&&o.indexOf("Safari")!==-1?(h="Chrome",s=(n=o.match(/Chrome\/([\d.]+)/))==null?void 0:n[1]):o.indexOf("Safari")!==-1&&o.indexOf("Chrome")===-1?(h="Safari",s=(r=o.match(/Version\/([\d.]+)/))==null?void 0:r[1]):o.indexOf("Opera")!==-1||o.indexOf("OPR")!==-1?(h="Opera",s=(i=o.match(/(Opera|OPR)\/([\d.]+)/))==null?void 0:i[2]):o.indexOf("MSIE")!==-1||o.indexOf("Trident")!==-1?(h="Internet Explorer",s=(a=o.match(/(MSIE |rv:)([\d.]+)/))==null?void 0:a[2]):(h="Unknown",s="Unknown"),{name:h,version:s}}function ye(t){return new Promise(e=>setTimeout(e,t))}function ve(){let t=navigator.userAgent,e;t.indexOf("Win")!==-1?e="Windows":t.indexOf("Mac")!==-1?e="Mac":t.indexOf("Linux")!==-1?e="Linux":t.indexOf("Android")!==-1?e="Android":t.indexOf("like Mac")!==-1||t.indexOf("iPhone")!==-1||t.indexOf("iPad")!==-1?e="iOS":e="Unknown";let n;return/Mobile|iPhone|iPod|Android/i.test(t)?n="Mobile":/Tablet|iPad/i.test(t)?n="Tablet":n="Desktop",{model:e,family:e,device:n}}var xe=class Q{constructor(e){l(this,"_parent"),l(this,"breadcrumbs",[]),l(this,"context",{}),l(this,"extra",{}),l(this,"tags",{}),l(this,"request"),l(this,"user"),this._parent=e}get parent(){return this._parent}child(){return new Q(this)}setRequest(e){return this.request=e,this}removeRequest(){return this.request=void 0,this}addBreadcrumb(e){return typeof e.timestamp>"u"&&(e.timestamp=new Date().toISOString()),this.breadcrumbs.push(e),this}setExtra(e,n){return this.extra[e]=n,this}removeExtra(e){return delete this.extra[e],this}setContext(e,n){return typeof n.type>"u"&&(n.type=e),this.context[e]=n,this}removeContext(e){return delete this.context[e],this}setTags(e){return this.tags=g(g({},this.tags),e),this}setTag(e,n){return this.tags[e]=n,this}removeTag(e){return delete this.tags[e],this}setUser(e){return this.user=e,this}removeUser(){return this.user=void 0,this}toBody(){let e=[],n=this;for(;n;)e.push(n),n=n.parent;return e.reverse().reduce((r,i)=>{var a;return r.breadcrumbs=[...(a=r.breadcrumbs)!=null?a:[],...i.breadcrumbs],r.extra=g(g({},r.extra),i.extra),r.contexts=g(g({},r.contexts),i.context),r.tags=g(g({},r.tags),i.tags),i.user&&(r.user=i.user),i.request&&(r.request=i.request),r},{breadcrumbs:[],extra:{},contexts:{},tags:{},request:void 0,user:void 0})}clear(){this.breadcrumbs=[],this.context={},this.tags={},this.user=void 0}},be=/^\s*at (?:(.*?) ?\()?((?:file|https?|blob|chrome-extension|address|native|eval|webpack|<anonymous>|[-a-z]+:|.*bundle|\/).*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,we=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:file|https?|blob|chrome|webpack|resource|moz-extension).*?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js))(?::(\d+))?(?::(\d+))?\s*$/i,Ee=/^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|webpack|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i,Ce=/^(?:(\w+):)\/\/(?:(\w+)(?::(\w+))?@)([\w.-]+)(?::(\d+))?\/(.+)/,S="?",W="An unknown error occurred",Re="0.0.4";function _e(t){for(let e=0;e<t.length;e++)t[e]=Math.floor(Math.random()*256);return t}function p(t){return(t+256).toString(16).substring(1)}function Oe(){let t=_e(new Array(16));return t[6]=t[6]&15|64,t[8]=t[8]&63|128,p(t[0])+p(t[1])+p(t[2])+p(t[3])+"-"+p(t[4])+p(t[5])+"-"+p(t[6])+p(t[7])+"-"+p(t[8])+p(t[9])+"-"+p(t[10])+p(t[11])+p(t[12])+p(t[13])+p(t[14])+p(t[15])}var Pe=[[be,"chrome"],[Ee,"winjs"],[we,"gecko"]];function Se(t){var e,n,r,i;if(!t.stack)return null;let a=[],o=(r=(n=(e=t.stack).split)==null?void 0:n.call(e,`
2
- `))!=null?r:[];for(let h=0;h<o.length;++h){let s=null,c=null,u=null;for(let[y,v]of Pe)if(c=y.exec(o[h]),c){u=v;break}if(!(!c||!u)){if(u==="chrome")s={filename:(i=c[2])!=null&&i.startsWith("address at ")?c[2].substring(11):c[2],function:c[1]||S,lineno:c[3]?+c[3]:null,colno:c[4]?+c[4]:null};else if(u==="winjs")s={filename:c[2],function:c[1]||S,lineno:+c[3],colno:c[4]?+c[4]:null};else if(u==="gecko")h===0&&!c[5]&&t.columnNumber!==void 0&&a.length>0&&(a[0].column=t.columnNumber+1),s={filename:c[3],function:c[1]||S,lineno:c[4]?+c[4]:null,colno:c[5]?+c[5]:null};else continue;!s.function&&s.lineno&&(s.function=S),a.push(s)}}return a.length?a.reverse():null}function Ie(t){let e=Se(t);return{type:t.name,value:t.message,stacktrace:{frames:e!=null?e:[]}}}function ke(t){let e=Ce.exec(t),n=e?e.slice(1):[];if(n.length!==6)throw new Error("Invalid DSN");let r=n[5].split("/"),i=r.slice(0,-1).join("/");return n[0]+"://"+n[3]+(n[4]?":"+n[4]:"")+(i?"/"+i:"")+"/api/"+r.pop()+"/envelope/?sentry_version=7&sentry_key="+n[1]+(n[2]?"&sentry_secret="+n[2]:"")}function je(t,e,n){var r,i;let a=g({event_id:Oe().replaceAll("-",""),platform:"javascript",sdk:{name:"@hcaptcha/sentry",version:Re},environment:e,release:n,timestamp:Date.now()/1e3},t.scope.toBody());if(t.type==="exception"){a.message=(i=(r=t.error)==null?void 0:r.message)!=null?i:"Unknown error",a.fingerprint=[a.message];let o=[],h=t.error;for(let s=0;s<5&&h&&(o.push(Ie(h)),!(!h.cause||!(h.cause instanceof Error)));s++)h=h.cause;a.exception={values:o.reverse()}}return t.type==="message"&&(a.message=t.message,a.level=t.level),a}function Ae(t){if(t instanceof Error)return t;if(typeof t=="string")return new Error(t);if(typeof t=="object"&&t!==null&&!Array.isArray(t)){let n=t,{message:r}=n,i=de(n,["message"]),a=new Error(typeof r=="string"?r:W);return Object.assign(a,i)}let e=new Error(W);return Object.assign(e,{cause:t})}function qe(t,e,n){return C(this,null,function*(){var r,i;try{if(typeof fetch<"u"&&typeof AbortSignal<"u"){let a;if(n){let s=new AbortController;a=s.signal,setTimeout(()=>s.abort(),n)}let o=yield fetch(t,K(g({},e),{signal:a})),h=yield o.text();return{status:o.status,body:h}}return yield new Promise((a,o)=>{var h,s;let c=new XMLHttpRequest;if(c.open((h=e==null?void 0:e.method)!=null?h:"GET",t),c.onload=()=>a({status:c.status,body:c.responseText}),c.onerror=()=>o(new Error("XHR Network Error")),e==null?void 0:e.headers)for(let[u,y]of Object.entries(e.headers))c.setRequestHeader(u,y);if(n){let u=setTimeout(()=>{c.abort(),o(new Error("Request timed out"))},n);c.onloadend=()=>{clearTimeout(u)}}c.send((s=e==null?void 0:e.body)==null?void 0:s.toString())})}catch(a){return{status:0,body:(i=(r=a==null?void 0:a.toString)==null?void 0:r.call(a))!=null?i:"Unknown error"}}})}var m,L=(m=class{constructor(t){l(this,"apiURL"),l(this,"dsn"),l(this,"environment"),l(this,"release"),l(this,"sampleRate"),l(this,"debug"),l(this,"_scope"),l(this,"shouldBuffer",!1),l(this,"bufferlimit",20),l(this,"buffer",[]);var e,n,r,i,a;this.environment=t.environment,this.release=t.release,this.sampleRate=(e=t.sampleRate)!=null?e:1,this.debug=(n=t.debug)!=null?n:!1,this._scope=(r=t.scope)!=null?r:new xe,this.apiURL=ke(t.dsn),this.dsn=t.dsn,this.shouldBuffer=(i=t.buffer)!=null?i:!1,this.bufferlimit=(a=t.bufferLimit)!=null?a:20}static init(t){m._instance||(m._instance=new m(t))}static get instance(){if(!m._instance)throw new Error("Sentry has not been initialized");return m._instance}log(...t){this.debug&&console.log(...t)}get scope(){return this._scope}static get scope(){return m.instance.scope}withScope(t){let e=this._scope.child();t(e)}static withScope(t){m.instance.withScope(t)}captureException(t,e){this.captureEvent({type:"exception",level:"error",error:Ae(t),scope:e!=null?e:this._scope})}static captureException(t,e){m.instance.captureException(t,e)}captureMessage(t,e="info",n){this.captureEvent({type:"message",level:e,message:t,scope:n!=null?n:this._scope})}static captureMessage(t,e="info",n){m.instance.captureMessage(t,e,n)}captureEvent(t){if(Math.random()>=this.sampleRate){this.log("Dropped event due to sample rate");return}if(this.shouldBuffer){if(this.buffer.length>=this.bufferlimit)return;this.buffer.push(t)}else this.sendEvent(t)}sendEvent(t,e=5e3){return C(this,null,function*(){try{this.log("Sending sentry event",t);let n=je(t,this.environment,this.release),r={event_id:n.event_id,dsn:this.dsn},i={type:"event"},a=JSON.stringify(r)+`
1
+ var ae=Object.defineProperty;var B=Object.getOwnPropertySymbols;var oe=Object.prototype.hasOwnProperty,ce=Object.prototype.propertyIsEnumerable;var D=(t,e,n)=>e in t?ae(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,$=(t,e)=>{for(var n in e||(e={}))oe.call(e,n)&&D(t,n,e[n]);if(B)for(var n of B(e))ce.call(e,n)&&D(t,n,e[n]);return t};var F=(t,e,n)=>new Promise((r,i)=>{var a=s=>{try{h(n.next(s))}catch(c){i(c)}},o=s=>{try{h(n.throw(s))}catch(c){i(c)}},h=s=>s.done?r(s.value):Promise.resolve(s.value).then(a,o);h((n=n.apply(t,e)).next())});import*as R from"react";var he=Object.defineProperty,le=Object.defineProperties,ue=Object.getOwnPropertyDescriptors,j=Object.getOwnPropertySymbols,V=Object.prototype.hasOwnProperty,J=Object.prototype.propertyIsEnumerable,q=(t,e,n)=>e in t?he(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,g=(t,e)=>{for(var n in e||(e={}))V.call(e,n)&&q(t,n,e[n]);if(j)for(var n of j(e))J.call(e,n)&&q(t,n,e[n]);return t},K=(t,e)=>le(t,ue(e)),de=(t,e)=>{var n={};for(var r in t)V.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&j)for(var r of j(t))e.indexOf(r)<0&&J.call(t,r)&&(n[r]=t[r]);return n},l=(t,e,n)=>(q(t,typeof e!="symbol"?e+"":e,n),n),C=(t,e,n)=>new Promise((r,i)=>{var a=s=>{try{h(n.next(s))}catch(c){i(c)}},o=s=>{try{h(n.throw(s))}catch(c){i(c)}},h=s=>s.done?r(s.value):Promise.resolve(s.value).then(a,o);h((n=n.apply(t,e)).next())}),pe="hCaptcha-script",k="hCaptchaOnLoad",N="script-error",b="@hCaptcha/loader";function fe(t){return Object.entries(t).filter(([,e])=>e||e===!1).map(([e,n])=>`${encodeURIComponent(e)}=${encodeURIComponent(String(n))}`).join("&")}function G(t){let e=t&&t.ownerDocument||document,n=e.defaultView||e.parentWindow||window;return{document:e,window:n}}function X(t){return t||document.head}function me(t){var e;t.setTag("source",b),t.setTag("url",document.URL),t.setContext("os",{UA:navigator.userAgent}),t.setContext("browser",g({},ge())),t.setContext("device",K(g({},ve()),{screen_width_pixels:screen.width,screen_height_pixels:screen.height,language:navigator.language,orientation:((e=screen.orientation)==null?void 0:e.type)||"Unknown",processor_count:navigator.hardwareConcurrency,platform:navigator.platform}))}function ge(){var t,e,n,r,i,a;let o=navigator.userAgent,h,s;return o.indexOf("Firefox")!==-1?(h="Firefox",s=(t=o.match(/Firefox\/([\d.]+)/))==null?void 0:t[1]):o.indexOf("Edg")!==-1?(h="Microsoft Edge",s=(e=o.match(/Edg\/([\d.]+)/))==null?void 0:e[1]):o.indexOf("Chrome")!==-1&&o.indexOf("Safari")!==-1?(h="Chrome",s=(n=o.match(/Chrome\/([\d.]+)/))==null?void 0:n[1]):o.indexOf("Safari")!==-1&&o.indexOf("Chrome")===-1?(h="Safari",s=(r=o.match(/Version\/([\d.]+)/))==null?void 0:r[1]):o.indexOf("Opera")!==-1||o.indexOf("OPR")!==-1?(h="Opera",s=(i=o.match(/(Opera|OPR)\/([\d.]+)/))==null?void 0:i[2]):o.indexOf("MSIE")!==-1||o.indexOf("Trident")!==-1?(h="Internet Explorer",s=(a=o.match(/(MSIE |rv:)([\d.]+)/))==null?void 0:a[2]):(h="Unknown",s="Unknown"),{name:h,version:s}}function ye(t){return new Promise(e=>setTimeout(e,t))}function ve(){let t=navigator.userAgent,e;t.indexOf("Win")!==-1?e="Windows":t.indexOf("Mac")!==-1?e="Mac":t.indexOf("Linux")!==-1?e="Linux":t.indexOf("Android")!==-1?e="Android":t.indexOf("like Mac")!==-1||t.indexOf("iPhone")!==-1||t.indexOf("iPad")!==-1?e="iOS":e="Unknown";let n;return/Mobile|iPhone|iPod|Android/i.test(t)?n="Mobile":/Tablet|iPad/i.test(t)?n="Tablet":n="Desktop",{model:e,family:e,device:n}}var xe=class Q{constructor(e){l(this,"_parent"),l(this,"breadcrumbs",[]),l(this,"context",{}),l(this,"extra",{}),l(this,"tags",{}),l(this,"request"),l(this,"user"),this._parent=e}get parent(){return this._parent}child(){return new Q(this)}setRequest(e){return this.request=e,this}removeRequest(){return this.request=void 0,this}addBreadcrumb(e){return typeof e.timestamp>"u"&&(e.timestamp=new Date().toISOString()),this.breadcrumbs.push(e),this}setExtra(e,n){return this.extra[e]=n,this}removeExtra(e){return delete this.extra[e],this}setContext(e,n){return typeof n.type>"u"&&(n.type=e),this.context[e]=n,this}removeContext(e){return delete this.context[e],this}setTags(e){return this.tags=g(g({},this.tags),e),this}setTag(e,n){return this.tags[e]=n,this}removeTag(e){return delete this.tags[e],this}setUser(e){return this.user=e,this}removeUser(){return this.user=void 0,this}toBody(){let e=[],n=this;for(;n;)e.push(n),n=n.parent;return e.reverse().reduce((r,i)=>{var a;return r.breadcrumbs=[...(a=r.breadcrumbs)!=null?a:[],...i.breadcrumbs],r.extra=g(g({},r.extra),i.extra),r.contexts=g(g({},r.contexts),i.context),r.tags=g(g({},r.tags),i.tags),i.user&&(r.user=i.user),i.request&&(r.request=i.request),r},{breadcrumbs:[],extra:{},contexts:{},tags:{},request:void 0,user:void 0})}clear(){this.breadcrumbs=[],this.context={},this.tags={},this.user=void 0}},be=/^\s*at (?:(.*?) ?\()?((?:file|https?|blob|chrome-extension|address|native|eval|webpack|<anonymous>|[-a-z]+:|.*bundle|\/).*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,we=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:file|https?|blob|chrome|webpack|resource|moz-extension).*?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js))(?::(\d+))?(?::(\d+))?\s*$/i,Ee=/^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|webpack|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i,Ce=/^(?:(\w+):)\/\/(?:(\w+)(?::(\w+))?@)([\w.-]+)(?::(\d+))?\/(.+)/,I="?",W="An unknown error occurred",Re="0.0.4";function _e(t){for(let e=0;e<t.length;e++)t[e]=Math.floor(Math.random()*256);return t}function p(t){return(t+256).toString(16).substring(1)}function Oe(){let t=_e(new Array(16));return t[6]=t[6]&15|64,t[8]=t[8]&63|128,p(t[0])+p(t[1])+p(t[2])+p(t[3])+"-"+p(t[4])+p(t[5])+"-"+p(t[6])+p(t[7])+"-"+p(t[8])+p(t[9])+"-"+p(t[10])+p(t[11])+p(t[12])+p(t[13])+p(t[14])+p(t[15])}var Pe=[[be,"chrome"],[Ee,"winjs"],[we,"gecko"]];function Ie(t){var e,n,r,i;if(!t.stack)return null;let a=[],o=(r=(n=(e=t.stack).split)==null?void 0:n.call(e,`
2
+ `))!=null?r:[];for(let h=0;h<o.length;++h){let s=null,c=null,u=null;for(let[y,v]of Pe)if(c=y.exec(o[h]),c){u=v;break}if(!(!c||!u)){if(u==="chrome")s={filename:(i=c[2])!=null&&i.startsWith("address at ")?c[2].substring(11):c[2],function:c[1]||I,lineno:c[3]?+c[3]:null,colno:c[4]?+c[4]:null};else if(u==="winjs")s={filename:c[2],function:c[1]||I,lineno:+c[3],colno:c[4]?+c[4]:null};else if(u==="gecko")h===0&&!c[5]&&t.columnNumber!==void 0&&a.length>0&&(a[0].column=t.columnNumber+1),s={filename:c[3],function:c[1]||I,lineno:c[4]?+c[4]:null,colno:c[5]?+c[5]:null};else continue;!s.function&&s.lineno&&(s.function=I),a.push(s)}}return a.length?a.reverse():null}function Se(t){let e=Ie(t);return{type:t.name,value:t.message,stacktrace:{frames:e!=null?e:[]}}}function ke(t){let e=Ce.exec(t),n=e?e.slice(1):[];if(n.length!==6)throw new Error("Invalid DSN");let r=n[5].split("/"),i=r.slice(0,-1).join("/");return n[0]+"://"+n[3]+(n[4]?":"+n[4]:"")+(i?"/"+i:"")+"/api/"+r.pop()+"/envelope/?sentry_version=7&sentry_key="+n[1]+(n[2]?"&sentry_secret="+n[2]:"")}function je(t,e,n){var r,i;let a=g({event_id:Oe().replaceAll("-",""),platform:"javascript",sdk:{name:"@hcaptcha/sentry",version:Re},environment:e,release:n,timestamp:Date.now()/1e3},t.scope.toBody());if(t.type==="exception"){a.message=(i=(r=t.error)==null?void 0:r.message)!=null?i:"Unknown error",a.fingerprint=[a.message];let o=[],h=t.error;for(let s=0;s<5&&h&&(o.push(Se(h)),!(!h.cause||!(h.cause instanceof Error)));s++)h=h.cause;a.exception={values:o.reverse()}}return t.type==="message"&&(a.message=t.message,a.level=t.level),a}function Ae(t){if(t instanceof Error)return t;if(typeof t=="string")return new Error(t);if(typeof t=="object"&&t!==null&&!Array.isArray(t)){let n=t,{message:r}=n,i=de(n,["message"]),a=new Error(typeof r=="string"?r:W);return Object.assign(a,i)}let e=new Error(W);return Object.assign(e,{cause:t})}function qe(t,e,n){return C(this,null,function*(){var r,i;try{if(typeof fetch<"u"&&typeof AbortSignal<"u"){let a;if(n){let s=new AbortController;a=s.signal,setTimeout(()=>s.abort(),n)}let o=yield fetch(t,K(g({},e),{signal:a})),h=yield o.text();return{status:o.status,body:h}}return yield new Promise((a,o)=>{var h,s;let c=new XMLHttpRequest;if(c.open((h=e==null?void 0:e.method)!=null?h:"GET",t),c.onload=()=>a({status:c.status,body:c.responseText}),c.onerror=()=>o(new Error("XHR Network Error")),e==null?void 0:e.headers)for(let[u,y]of Object.entries(e.headers))c.setRequestHeader(u,y);if(n){let u=setTimeout(()=>{c.abort(),o(new Error("Request timed out"))},n);c.onloadend=()=>{clearTimeout(u)}}c.send((s=e==null?void 0:e.body)==null?void 0:s.toString())})}catch(a){return{status:0,body:(i=(r=a==null?void 0:a.toString)==null?void 0:r.call(a))!=null?i:"Unknown error"}}})}var m,L=(m=class{constructor(t){l(this,"apiURL"),l(this,"dsn"),l(this,"environment"),l(this,"release"),l(this,"sampleRate"),l(this,"debug"),l(this,"_scope"),l(this,"shouldBuffer",!1),l(this,"bufferlimit",20),l(this,"buffer",[]);var e,n,r,i,a;this.environment=t.environment,this.release=t.release,this.sampleRate=(e=t.sampleRate)!=null?e:1,this.debug=(n=t.debug)!=null?n:!1,this._scope=(r=t.scope)!=null?r:new xe,this.apiURL=ke(t.dsn),this.dsn=t.dsn,this.shouldBuffer=(i=t.buffer)!=null?i:!1,this.bufferlimit=(a=t.bufferLimit)!=null?a:20}static init(t){m._instance||(m._instance=new m(t))}static get instance(){if(!m._instance)throw new Error("Sentry has not been initialized");return m._instance}log(...t){this.debug&&console.log(...t)}get scope(){return this._scope}static get scope(){return m.instance.scope}withScope(t){let e=this._scope.child();t(e)}static withScope(t){m.instance.withScope(t)}captureException(t,e){this.captureEvent({type:"exception",level:"error",error:Ae(t),scope:e!=null?e:this._scope})}static captureException(t,e){m.instance.captureException(t,e)}captureMessage(t,e="info",n){this.captureEvent({type:"message",level:e,message:t,scope:n!=null?n:this._scope})}static captureMessage(t,e="info",n){m.instance.captureMessage(t,e,n)}captureEvent(t){if(Math.random()>=this.sampleRate){this.log("Dropped event due to sample rate");return}if(this.shouldBuffer){if(this.buffer.length>=this.bufferlimit)return;this.buffer.push(t)}else this.sendEvent(t)}sendEvent(t,e=5e3){return C(this,null,function*(){try{this.log("Sending sentry event",t);let n=je(t,this.environment,this.release),r={event_id:n.event_id,dsn:this.dsn},i={type:"event"},a=JSON.stringify(r)+`
3
3
  `+JSON.stringify(i)+`
4
- `+JSON.stringify(n),o=yield qe(this.apiURL,{method:"POST",headers:{"Content-Type":"application/x-sentry-envelope"},body:a},e);this.log("Sentry response",o.status),o.status!==200&&(console.log(o.body),console.error("Failed to send event to Sentry",o))}catch(n){console.error("Failed to send event",n)}})}flush(t=5e3){return C(this,null,function*(){try{this.log("Flushing sentry events",this.buffer.length);let e=this.buffer.splice(0,this.buffer.length).map(n=>this.sendEvent(n,t));yield Promise.all(e),this.log("Flushed all events")}catch(e){console.error("Failed to flush events",e)}})}static flush(t=5e3){return m.instance.flush(t)}static reset(){m._instance=void 0}},l(m,"_instance"),m),Le="https://d233059272824702afc8c43834c4912d@sentry.hcaptcha.com/6",Me="2.3.0",Te="production";function Ue(t=!0){if(!t)return z();L.init({dsn:Le,release:Me,environment:Te});let e=L.scope;return me(e),z(e)}function z(t=null){return{addBreadcrumb:e=>{t&&t.addBreadcrumb(e)},captureRequest:e=>{t&&t.setRequest(e)},captureException:e=>{t&&L.captureException(e,t)}}}function He({scriptLocation:t,query:e,loadAsync:n=!0,crossOrigin:r="anonymous",apihost:i="https://js.hcaptcha.com",cleanup:a=!1,secureApi:o=!1,scriptSource:h=""}={},s){let c=X(t),u=G(c);return new Promise((y,v)=>{let d=u.document.createElement("script");d.id=pe,h?d.src=`${h}?onload=${k}`:o?d.src=`${i}/1/secure-api.js?onload=${k}`:d.src=`${i}/1/api.js?onload=${k}`,d.crossOrigin=r,d.async=n;let w=(x,E)=>{try{!o&&a&&c.removeChild(d),E(x)}catch(P){v(P)}};d.onload=x=>w(x,y),d.onerror=x=>{s&&s(d.src),w(x,v)},d.src+=e!==""?`&${e}`:"",c.appendChild(d)})}var I=[];function Be(t={cleanup:!1},e){try{e.addBreadcrumb({category:b,message:"hCaptcha loader params",data:t});let n=X(t.scriptLocation),r=G(n),i=I.find(({scope:o})=>o===r.window);if(i)return e.addBreadcrumb({category:b,message:"hCaptcha already loaded"}),i.promise;let a=new Promise((o,h)=>C(this,null,function*(){try{r.window[k]=()=>{e.addBreadcrumb({category:b,message:"hCaptcha script called onload function"}),o(r.window.hcaptcha)};let s=fe({custom:t.custom,render:t.render,sentry:t.sentry,assethost:t.assethost,imghost:t.imghost,reportapi:t.reportapi,endpoint:t.endpoint,host:t.host,recaptchacompat:t.recaptchacompat,hl:t.hl,uj:t.uj});yield He(g({query:s},t),c=>{e.captureRequest({url:c,method:"GET"})}),e.addBreadcrumb({category:b,message:"hCaptcha loaded",data:i})}catch(s){e.addBreadcrumb({category:b,message:"hCaptcha failed to load"});let c=I.findIndex(u=>u.scope===r.window);c!==-1&&I.splice(c,1),h(new Error(N))}}));return I.push({promise:a,scope:r.window}),a}catch(n){return e.captureException(n),Promise.reject(new Error(N))}}function Y(t,e,n=0){return C(this,null,function*(){var r,i;let a=(r=t.maxRetries)!=null?r:2,o=(i=t.retryDelay)!=null?i:1e3,h=n<a?"Retry loading hCaptcha Api":"Exceeded maximum retries";try{return yield Be(t,e)}catch(s){return e.addBreadcrumb({category:b,message:h}),n>=a?(e.captureException(s),Promise.reject(s)):(e.addBreadcrumb({category:b,message:`Waiting ${o}ms before retry attempt ${n+1}`}),yield ye(o),n+=1,Y(t,e,n))}})}function Z(){return C(this,arguments,function*(t={}){let e=Ue(t.sentry);return yield Y(t,e)})}function M(t){let e=t&&t.ownerDocument||document,n=e.defaultView||e.parentWindow||window;return{document:e,window:n}}function T(t){return t||document.head}var O=class extends R.Component{constructor(e){super(e),this._hcaptcha=void 0,this.renderCaptcha=this.renderCaptcha.bind(this),this.resetCaptcha=this.resetCaptcha.bind(this),this.removeCaptcha=this.removeCaptcha.bind(this),this.isReady=this.isReady.bind(this),this._onReady=null,this.loadCaptcha=this.loadCaptcha.bind(this),this.handleOnLoad=this.handleOnLoad.bind(this),this.handleSubmit=this.handleSubmit.bind(this),this.handleExpire=this.handleExpire.bind(this),this.handleError=this.handleError.bind(this),this.handleOpen=this.handleOpen.bind(this),this.handleClose=this.handleClose.bind(this),this.handleChallengeExpired=this.handleChallengeExpired.bind(this),this.ref=R.createRef(),this.apiScriptRequested=!1,this.sentryHub=null,this.captchaId="",this._pendingExecute=null,this.state={isApiReady:!1,isRemoved:!1,elementId:e.id}}componentDidMount(){let e=T(this.props.scriptLocation),n=M(e);if(this._hcaptcha=n.window.hcaptcha||void 0,typeof this._hcaptcha!="undefined"){this.setState({isApiReady:!0},()=>{this.renderCaptcha()});return}this.loadCaptcha()}componentWillUnmount(){let e=this._hcaptcha,n=this.captchaId;this._cancelPendingExecute("react-component-unmounted"),this.isReady()&&(e.reset(n),e.remove(n))}shouldComponentUpdate(e,n){return!(this.state.isApiReady!==n.isApiReady||this.state.isRemoved!==n.isRemoved)}componentDidUpdate(e){["sitekey","size","theme","tabindex","languageOverride","endpoint"].every(i=>e[i]===this.props[i])||this.removeCaptcha(()=>{this.renderCaptcha()})}loadCaptcha(){if(this.apiScriptRequested)return;let{apihost:e,assethost:n,endpoint:r,host:i,imghost:a,languageOverride:o,reCaptchaCompat:h,reportapi:s,sentry:c,custom:u,loadAsync:y,scriptLocation:v,scriptSource:d,secureApi:w,cleanup:x=!0,userJourneys:E}=this.props;Z({render:"explicit",apihost:e,assethost:n,endpoint:r,hl:o,host:i,imghost:a,recaptchacompat:h===!1?"off":null,reportapi:s,sentry:c,custom:u,loadAsync:y,scriptLocation:v,scriptSource:d,secureApi:w,cleanup:x,uj:E!==void 0?E:!1}).then(this.handleOnLoad,this.handleError).catch(this.handleError),this.apiScriptRequested=!0}renderCaptcha(e){let{onReady:n}=this.props,{isApiReady:r}=this.state,i=this.captchaId;if(!r||i)return;let a=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}),h=this._hcaptcha.render(this.ref.current,a);this.captchaId=h,this.setState({isRemoved:!1},()=>{e&&e(),n&&n(),this._onReady&&this._onReady(h)})}resetCaptcha(){let e=this._hcaptcha,n=this.captchaId;this.isReady()&&(e.reset(n),this._cancelPendingExecute("hcaptcha-reset"))}removeCaptcha(e){let n=this._hcaptcha,r=this.captchaId;this._cancelPendingExecute("hcaptcha-removed"),this.isReady()&&this.setState({isRemoved:!0},()=>{this.captchaId="",n.remove(r),e&&e()})}handleOnLoad(){this.setState({isApiReady:!0},()=>{let e=T(this.props.scriptLocation),n=M(e);this._hcaptcha=n.window.hcaptcha,this.renderCaptcha(()=>{let{onLoad:r}=this.props;r&&r()})})}handleSubmit(e){let{onVerify:n}=this.props,{isRemoved:r}=this.state,i=this._hcaptcha,a=this.captchaId;if(typeof i=="undefined"||r)return;let o=i.getResponse(a),h=i.getRespKey(a);n&&n(o,h)}handleExpire(){let{onExpire:e}=this.props,n=this._hcaptcha,r=this.captchaId;this.isReady()&&(n.reset(r),e&&e())}handleError(e){let{onError:n}=this.props,r=this._hcaptcha,i=this.captchaId;this.isReady()&&r.reset(i),n&&n(e)}isReady(){let{isApiReady:e,isRemoved:n}=this.state;return e&&!n}_cancelPendingExecute(e){if(!this._pendingExecute)return;let n=this._pendingExecute;this._pendingExecute=null;let r=new Error(e);n.reject(r)}handleOpen(){!this.isReady()||!this.props.onOpen||this.props.onOpen()}handleClose(){!this.isReady()||!this.props.onClose||this.props.onClose()}handleChallengeExpired(){!this.isReady()||!this.props.onChalExpired||this.props.onChalExpired()}execute(e=null){e=typeof e=="object"?e:null;try{let n=this._hcaptcha,r=this.captchaId;if(e&&e.async&&this._pendingExecute&&this._cancelPendingExecute("hcaptcha-execute-replaced"),!this.isReady())return e&&e.async?new Promise((a,o)=>{this._pendingExecute={resolve:a,reject:o},this._onReady=h=>{if(this._pendingExecute)try{let s=n.execute(h,e);s&&typeof s.then=="function"?s.then(c=>{this._pendingExecute=null,a(c)}).catch(c=>{this._pendingExecute=null,o(c)}):(this._pendingExecute=null,o(new Error("hcaptcha-execute-no-promise")))}catch(s){this._pendingExecute=null,o(s)}}}):(this._onReady=a=>{n.execute(a,e)},null);let i=n.execute(r,e);return e&&e.async&&i&&typeof i.then=="function"?new Promise((a,o)=>{this._pendingExecute={resolve:a,reject:o},i.then(h=>{this._pendingExecute=null,a(h)}).catch(h=>{this._pendingExecute=null,o(h)})}):i}catch(n){return e&&e.async?Promise.reject(n):null}}close(){let e=this._hcaptcha,n=this.captchaId;if(this._cancelPendingExecute("hcaptcha-closed"),!!this.isReady())return e.close(n)}setData(e){let n=this._hcaptcha,r=this.captchaId;this.isReady()&&(e&&typeof e!="object"&&(e=null),n.setData(r,e))}getResponse(){return this._hcaptcha.getResponse(this.captchaId)}getRespKey(){return this._hcaptcha.getRespKey(this.captchaId)}render(){let{elementId:e}=this.state;return R.createElement("div",{ref:this.ref,id:e})}};import{useContext as $e}from"react";import{createContext as De}from"react";var A=De();var ee=()=>$e(A);import te,{useEffect as Fe,useRef as Ne,useState as U}from"react";function ne({sitekey:t=null,size:e="normal",theme:n="light",rqdata:r=null,languageOverride:i=null,onVerify:a,onError:o,children:h}){let s=Ne(null),[c,u]=U(!1),[y,v]=U(null),[d,w]=U(null),x=()=>{u(!0)},E=f=>{w(f),o&&o(f)},P=()=>{v(null)},se=f=>{v(f),a&&a(f)},ie=(...mt)=>F(this,[...mt],function*(f={}){try{if(!c)throw new Error("hCaptcha not ready");y&&H();let{response:_}=yield s.current.execute($({async:!0},f.rqdata?{rqdata:f.rqdata}:{}));return v(_),_}catch(_){w(_),o&&o(_)}}),H=()=>{var f;(f=s==null?void 0:s.current)==null||f.resetCaptcha()};return Fe(()=>{var f;r&&((f=s==null?void 0:s.current)==null||f.setData(r))},[r]),te.createElement(A.Provider,{value:{sitekey:t,error:d,token:y,ready:c,executeInstance:ie,resetInstance:H}},h,te.createElement(re,{sitekey:t,size:e,theme:n,languageOverride:i,onReady:x,onVerify:se,onExpire:P,onError:E,ref:s}))}var re=O;export{O as HCaptcha,ne as HCaptchaProvider,re as default,ee as useHCaptcha};
4
+ `+JSON.stringify(n),o=yield qe(this.apiURL,{method:"POST",headers:{"Content-Type":"application/x-sentry-envelope"},body:a},e);this.log("Sentry response",o.status),o.status!==200&&(console.log(o.body),console.error("Failed to send event to Sentry",o))}catch(n){console.error("Failed to send event",n)}})}flush(t=5e3){return C(this,null,function*(){try{this.log("Flushing sentry events",this.buffer.length);let e=this.buffer.splice(0,this.buffer.length).map(n=>this.sendEvent(n,t));yield Promise.all(e),this.log("Flushed all events")}catch(e){console.error("Failed to flush events",e)}})}static flush(t=5e3){return m.instance.flush(t)}static reset(){m._instance=void 0}},l(m,"_instance"),m),Le="https://d233059272824702afc8c43834c4912d@sentry.hcaptcha.com/6",Me="2.3.0",Te="production";function Ue(t=!0){if(!t)return z();L.init({dsn:Le,release:Me,environment:Te});let e=L.scope;return me(e),z(e)}function z(t=null){return{addBreadcrumb:e=>{t&&t.addBreadcrumb(e)},captureRequest:e=>{t&&t.setRequest(e)},captureException:e=>{t&&L.captureException(e,t)}}}function He({scriptLocation:t,query:e,loadAsync:n=!0,crossOrigin:r="anonymous",apihost:i="https://js.hcaptcha.com",cleanup:a=!1,secureApi:o=!1,scriptSource:h=""}={},s){let c=X(t),u=G(c);return new Promise((y,v)=>{let d=u.document.createElement("script");d.id=pe,h?d.src=`${h}?onload=${k}`:o?d.src=`${i}/1/secure-api.js?onload=${k}`:d.src=`${i}/1/api.js?onload=${k}`,d.crossOrigin=r,d.async=n;let w=(x,E)=>{try{!o&&a&&c.removeChild(d),E(x)}catch(P){v(P)}};d.onload=x=>w(x,y),d.onerror=x=>{s&&s(d.src),w(x,v)},d.src+=e!==""?`&${e}`:"",c.appendChild(d)})}var S=[];function Be(t={cleanup:!1},e){try{e.addBreadcrumb({category:b,message:"hCaptcha loader params",data:t});let n=X(t.scriptLocation),r=G(n),i=S.find(({scope:o})=>o===r.window);if(i)return e.addBreadcrumb({category:b,message:"hCaptcha already loaded"}),i.promise;let a=new Promise((o,h)=>C(this,null,function*(){try{r.window[k]=()=>{e.addBreadcrumb({category:b,message:"hCaptcha script called onload function"}),o(r.window.hcaptcha)};let s=fe({custom:t.custom,render:t.render,sentry:t.sentry,assethost:t.assethost,imghost:t.imghost,reportapi:t.reportapi,endpoint:t.endpoint,host:t.host,recaptchacompat:t.recaptchacompat,hl:t.hl,uj:t.uj});yield He(g({query:s},t),c=>{e.captureRequest({url:c,method:"GET"})}),e.addBreadcrumb({category:b,message:"hCaptcha loaded",data:i})}catch(s){e.addBreadcrumb({category:b,message:"hCaptcha failed to load"});let c=S.findIndex(u=>u.scope===r.window);c!==-1&&S.splice(c,1),h(new Error(N))}}));return S.push({promise:a,scope:r.window}),a}catch(n){return e.captureException(n),Promise.reject(new Error(N))}}function Y(t,e,n=0){return C(this,null,function*(){var r,i;let a=(r=t.maxRetries)!=null?r:2,o=(i=t.retryDelay)!=null?i:1e3,h=n<a?"Retry loading hCaptcha Api":"Exceeded maximum retries";try{return yield Be(t,e)}catch(s){return e.addBreadcrumb({category:b,message:h}),n>=a?(e.captureException(s),Promise.reject(s)):(e.addBreadcrumb({category:b,message:`Waiting ${o}ms before retry attempt ${n+1}`}),yield ye(o),n+=1,Y(t,e,n))}})}function Z(){return C(this,arguments,function*(t={}){let e=Ue(t.sentry);return yield Y(t,e)})}function M(t){let e=t&&t.ownerDocument||document,n=e.defaultView||e.parentWindow||window;return{document:e,window:n}}function T(t){return t||document.head}var O=class extends R.Component{constructor(e){super(e),this._hcaptcha=void 0,this.renderCaptcha=this.renderCaptcha.bind(this),this.resetCaptcha=this.resetCaptcha.bind(this),this.removeCaptcha=this.removeCaptcha.bind(this),this.isReady=this.isReady.bind(this),this._onReady=null,this.loadCaptcha=this.loadCaptcha.bind(this),this.handleOnLoad=this.handleOnLoad.bind(this),this.handleSubmit=this.handleSubmit.bind(this),this.handleExpire=this.handleExpire.bind(this),this.handleError=this.handleError.bind(this),this.handleOpen=this.handleOpen.bind(this),this.handleClose=this.handleClose.bind(this),this.handleChallengeExpired=this.handleChallengeExpired.bind(this),this.ref=R.createRef(),this.apiScriptRequested=!1,this.sentryHub=null,this.captchaId="",this._pendingExecute=null,this.state={isApiReady:!1,isRemoved:!1,elementId:e.id}}componentDidMount(){let e=T(this.props.scriptLocation),n=M(e);if(this._hcaptcha=n.window.hcaptcha||void 0,typeof this._hcaptcha!="undefined"){this.setState({isApiReady:!0},()=>{this.renderCaptcha()});return}this.loadCaptcha()}componentWillUnmount(){let e=this._hcaptcha,n=this.captchaId;if(this._cancelPendingExecute("react-component-unmounted"),!!this.isReady())try{e.reset(n),e.remove(n)}catch(r){}finally{this.captchaId="",this._onReady=null}}shouldComponentUpdate(e,n){return!(this.state.isApiReady!==n.isApiReady||this.state.isRemoved!==n.isRemoved)}componentDidUpdate(e){["sitekey","size","theme","tabindex","languageOverride","endpoint"].every(i=>e[i]===this.props[i])||this.removeCaptcha(()=>{this.renderCaptcha()})}loadCaptcha(){if(this.apiScriptRequested)return;let{apihost:e,assethost:n,endpoint:r,host:i,imghost:a,languageOverride:o,reCaptchaCompat:h,reportapi:s,sentry:c,custom:u,loadAsync:y,scriptLocation:v,scriptSource:d,secureApi:w,cleanup:x=!0,userJourneys:E}=this.props;Z({render:"explicit",apihost:e,assethost:n,endpoint:r,hl:o,host:i,imghost:a,recaptchacompat:h===!1?"off":null,reportapi:s,sentry:c,custom:u,loadAsync:y,scriptLocation:v,scriptSource:d,secureApi:w,cleanup:x,uj:E!==void 0?E:!1}).then(this.handleOnLoad,this.handleError).catch(this.handleError),this.apiScriptRequested=!0}renderCaptcha(e){let{onReady:n}=this.props,{isApiReady:r}=this.state,i=this.captchaId;if(!r||i)return;let a=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}),h=this._hcaptcha.render(this.ref.current,a);this.captchaId=h,this.setState({isRemoved:!1},()=>{e&&e(),n&&n(),this._onReady&&this._onReady(h)})}resetCaptcha(){let e=this._hcaptcha,n=this.captchaId;this.isReady()&&(e.reset(n),this._cancelPendingExecute("hcaptcha-reset"))}removeCaptcha(e){let n=this._hcaptcha,r=this.captchaId;this._cancelPendingExecute("hcaptcha-removed"),this.isReady()&&this.setState({isRemoved:!0},()=>{this.captchaId="",n.remove(r),e&&e()})}handleOnLoad(){this.setState({isApiReady:!0},()=>{let e=T(this.props.scriptLocation),n=M(e);this._hcaptcha=n.window.hcaptcha,this.renderCaptcha(()=>{let{onLoad:r}=this.props;r&&r()})})}handleSubmit(e){let{onVerify:n}=this.props,{isRemoved:r}=this.state,i=this._hcaptcha,a=this.captchaId;if(typeof i=="undefined"||r)return;let o=i.getResponse(a),h=i.getRespKey(a);n&&n(o,h)}handleExpire(){let{onExpire:e}=this.props,n=this._hcaptcha,r=this.captchaId;this.isReady()&&(n.reset(r),e&&e())}handleError(e){let{onError:n}=this.props,r=this._hcaptcha,i=this.captchaId;this.isReady()&&r.reset(i),n&&n(e)}isReady(){let{isApiReady:e,isRemoved:n}=this.state;return e&&!n}_cancelPendingExecute(e){if(!this._pendingExecute)return;let n=this._pendingExecute;this._pendingExecute=null;let r=new Error(e);n.reject(r)}handleOpen(){!this.isReady()||!this.props.onOpen||this.props.onOpen()}handleClose(){!this.isReady()||!this.props.onClose||this.props.onClose()}handleChallengeExpired(){!this.isReady()||!this.props.onChalExpired||this.props.onChalExpired()}execute(e=null){e=typeof e=="object"?e:null;try{let n=this._hcaptcha,r=this.captchaId;if(e&&e.async&&this._pendingExecute&&this._cancelPendingExecute("hcaptcha-execute-replaced"),!this.isReady())return e&&e.async?new Promise((a,o)=>{this._pendingExecute={resolve:a,reject:o},this._onReady=h=>{if(this._pendingExecute)try{let s=n.execute(h,e);s&&typeof s.then=="function"?s.then(c=>{this._pendingExecute=null,a(c)}).catch(c=>{this._pendingExecute=null,o(c)}):(this._pendingExecute=null,o(new Error("hcaptcha-execute-no-promise")))}catch(s){this._pendingExecute=null,o(s)}}}):(this._onReady=a=>{n.execute(a,e)},null);let i=n.execute(r,e);return e&&e.async&&i&&typeof i.then=="function"?new Promise((a,o)=>{this._pendingExecute={resolve:a,reject:o},i.then(h=>{this._pendingExecute=null,a(h)}).catch(h=>{this._pendingExecute=null,o(h)})}):i}catch(n){return e&&e.async?Promise.reject(n):null}}close(){let e=this._hcaptcha,n=this.captchaId;if(this._cancelPendingExecute("hcaptcha-closed"),!!this.isReady())return e.close(n)}setData(e){let n=this._hcaptcha,r=this.captchaId;this.isReady()&&(e&&typeof e!="object"&&(e=null),n.setData(r,e))}getResponse(){return this._hcaptcha.getResponse(this.captchaId)}getRespKey(){return this._hcaptcha.getRespKey(this.captchaId)}render(){let{elementId:e}=this.state;return R.createElement("div",{ref:this.ref,id:e})}};import{useContext as $e}from"react";import{createContext as De}from"react";var A=De();var ee=()=>$e(A);import te,{useEffect as Fe,useRef as Ne,useState as U}from"react";function ne({sitekey:t=null,size:e="normal",theme:n="light",rqdata:r=null,languageOverride:i=null,onVerify:a,onError:o,children:h}){let s=Ne(null),[c,u]=U(!1),[y,v]=U(null),[d,w]=U(null),x=()=>{u(!0)},E=f=>{w(f),o&&o(f)},P=()=>{v(null)},se=f=>{v(f),a&&a(f)},ie=(...mt)=>F(this,[...mt],function*(f={}){try{if(!c)throw new Error("hCaptcha not ready");y&&H();let{response:_}=yield s.current.execute($({async:!0},f.rqdata?{rqdata:f.rqdata}:{}));return v(_),_}catch(_){w(_),o&&o(_)}}),H=()=>{var f;(f=s==null?void 0:s.current)==null||f.resetCaptcha()};return Fe(()=>{var f;r&&((f=s==null?void 0:s.current)==null||f.setData(r))},[r]),te.createElement(A.Provider,{value:{sitekey:t,error:d,token:y,ready:c,executeInstance:ie,resetInstance:H}},h,te.createElement(re,{sitekey:t,size:e,theme:n,languageOverride:i,onReady:x,onVerify:se,onExpire:P,onError:E,ref:s}))}var re=O;export{O as HCaptcha,ne as HCaptchaProvider,re as default,ee as useHCaptcha};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hcaptcha/react-hcaptcha",
3
3
  "description": "A React library for hCaptcha",
4
- "version": "2.0.1",
4
+ "version": "2.0.2",
5
5
  "author": "hCaptcha team and contributors",
6
6
  "license": "MIT",
7
7
  "repository": {