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,c,IAEUC,EAGC7C,E,kDAHQ,O,sBAAA,C,EAAM0C,EAAQ3C,QAAQX,I,OACrC,OADMyD,EAAS,UACJ1C,QAAgB,C,EAAAhB,aAAAA,EAAAA,EAAU0D,EAAO7C,QACrC,C,EAAAyC,EAASI,EAAOxC,Q,OAEvB,OADOL,EAAAA,EAAAA,OACA,C,EAAAb,aAAAA,EAAAA,EAAUa,I,oBAErB,KARe4C,MAAAA,KAAAA,U,CASfF,EAAQxD,Q,kBATO0D,EAAAA,MAAAA,KAAAA,U,GAUjB,GAAG,CAACxD,EAAQsD,EAASvD,EAASsD,IACvB,IACT,C,+ICGgBE,C,YA/BW,O,IAC4B,OA8BhD,SAASA,IACd,IAAMG,GAAYC,EAAAA,EAAAA,YAAW1E,EAAAA,kBAC7B,IAAKyE,EACH,MAAM,IAAI7C,MAAM,gEAElB,OAAO6C,CACT,C","sources":["webpack://webstaurantstore/./__alias__/re-captcha/index.tsx","webpack://webstaurantstore/./__alias__/re-captcha/re-captcha-disclaimer.tsx","webpack://webstaurantstore/./__alias__/re-captcha/re-captcha-provider.tsx","webpack://webstaurantstore/./__alias__/re-captcha/re-captcha.tsx","webpack://webstaurantstore/./__alias__/re-captcha/use-re-captcha.tsx"],"sourcesContent":["export * from \"./use-re-captcha\";\nexport * from \"./re-captcha-provider\";\nexport * from \"./re-captcha-disclaimer\";\nexport * from \"./re-captcha\";","/* eslint-disable import/prefer-default-export */\nimport clsx from \"clsx\";\nimport React, { HTMLAttributes } from \"react\";\ntype RecaptchaDisclaimerProps = HTMLAttributes & {\n anchorProps?: HTMLAttributes;\n};\nexport function RecaptchaDisclaimer({\n anchorProps,\n className,\n ...rest\n}: RecaptchaDisclaimerProps) {\n return \n This form is protected by reCAPTCHA and the Google\n
\n \n Privacy Policy\n {\" \"}\n and{\" \"}\n \n Terms of Service\n {\" \"}\n apply.\n
;\n}","import React, { createContext, ReactNode, useCallback, useEffect, useMemo, useRef } from \"react\";\nimport { logException } from \"@wss/error-tracking\";\nimport { Throwable } from \"@wss/error-tracking/throwable\";\nimport { env } from \"~/common/Environment\";\ntype Recaptcha = {\n execute: (key: string, opts?: {\n action?: string;\n }) => Promise;\n ready: (cb: () => void) => void;\n};\nconst recaptchaSiteKeys = {\n local: \"6Lf0ILAUAAAAAAG_5Z5G2ihgXtxsjvw6CKYt3OHs\",\n development: \"6Lf0ILAUAAAAAAG_5Z5G2ihgXtxsjvw6CKYt3OHs\",\n test: \"6Lf0ILAUAAAAAAG_5Z5G2ihgXtxsjvw6CKYt3OHs\",\n production: \"6LcMB7EUAAAAAIBgYhbNBrCNyKHlQtMgVYTjpT8V\"\n};\n\n/** Preflight uses the dev key */\nconst recaptchaSiteKey = recaptchaSiteKeys[env.isPreflight ? \"development\" : env.current];\nconst scriptId = \"google-recaptcha-v3\";\nexport type RecaptchaContextType = {\n /** See {@link useReCaptcha } for more information on how to use ReCaptcha. */\n execute: (action?: string) => Promise>;\n /** Allows a consumer to wait for the re-captcha script to be loaded */\n onLoad: (cb: () => void) => void;\n};\nexport const RecaptchaContext = createContext(null);\ntype ReCaptchaProviderProps = {\n action?: string;\n language?: string;\n useEnterprise?: boolean;\n children?: ReactNode;\n};\n\n/**\n * Provides all pages in SF with the ability to use ReCaptcha.\n *\n * See {@link useReCaptcha } for more information on how to use ReCaptcha.\n *\n * {@link https://developers.google.com/recaptcha/docs/v3 ReCaptcha Documentation}\n *\n * {@link https://github.com/t49tran/react-google-recaptcha-v3 Github Reference}\n */\nexport function ReCaptchaProvider({\n action: defaultAction,\n useEnterprise = false,\n language,\n children\n}: ReCaptchaProviderProps): JSX.Element {\n const instanceRef = useRef(null);\n const subs = useRef void>>(new Set());\n const onLoad: RecaptchaContextType[\"onLoad\"] = useCallback(function handleOnLoad(cb: () => void): void {\n if (!instanceRef.current) {\n subs.current.add(cb);\n return;\n }\n cb();\n }, []);\n const execute: RecaptchaContextType[\"execute\"] = useCallback(async function onExecute(action?: string): ReturnType {\n if (!instanceRef.current) {\n const error = new Error(\"Google Recaptcha has not been loaded\");\n await logException(error);\n return {\n isError: true,\n error\n };\n }\n try {\n const result = await instanceRef.current.execute(recaptchaSiteKey, {\n action: action ?? defaultAction\n });\n return {\n isError: false,\n value: result\n };\n } catch (error) {\n await logException(error);\n return {\n isError: true,\n error\n };\n }\n }, [defaultAction]);\n const handleLoad = useCallback(async function onLoad(): Promise {\n if (!window.grecaptcha) {\n await logException(new Error(\"Recaptcha was no able to load\"));\n return;\n }\n const ref: Recaptcha = useEnterprise ? window.grecaptcha.enterprise : window.grecaptcha;\n ref.ready(function handleRecaptchaReady() {\n instanceRef.current = ref;\n subs.current.forEach(sub => sub());\n subs.current.clear();\n });\n }, [useEnterprise]);\n const handleError = useCallback(async function onError() {\n // We ignore the error because the execute function will return a Throwable error allowing the consumer to determine how to notify the user that re-captcha has failed to load.\n }, []);\n const handleUnload = useCallback(function onUnload() {\n const nodeBadge = document.querySelector(\".grecaptcha-badge\");\n if (nodeBadge && nodeBadge.parentNode) {\n document.body.removeChild(nodeBadge.parentNode);\n }\n instanceRef.current = null;\n const js = document.querySelector(`#${scriptId}`);\n js?.removeEventListener(\"load\", handleLoad);\n js?.removeEventListener(\"error\", handleError);\n }, [handleError, handleLoad]);\n useEffect(function initRecaptchaScript() {\n const script = document.querySelector(`#${scriptId}`);\n if (script) {\n if (window.grecaptcha) {\n // The ReCaptcha script has already loaded and executed\n handleLoad();\n } else {\n // Wait until the script finishes loading\n script.addEventListener(\"load\", handleLoad);\n }\n return handleUnload;\n }\n const scriptName = useEnterprise ? \"enterprise.js\" : \"api.js\";\n const url = new URL(`https://www.google.com/recaptcha/${scriptName}`);\n url.searchParams.append(\"render\", recaptchaSiteKey);\n if (language) {\n url.searchParams.append(\"hl\", language);\n }\n const js = document.createElement(\"script\");\n js.id = scriptId;\n js.src = url.href;\n js.addEventListener(\"load\", handleLoad);\n js.addEventListener(\"error\", handleError);\n document.head.appendChild(js);\n return handleUnload;\n }, [handleError, handleLoad, handleUnload, language, useEnterprise]);\n const value = useMemo(() => ({\n execute,\n onLoad\n }), [execute, onLoad]);\n return \n {children}\n ;\n}","/* eslint-disable import/prefer-default-export */\nimport { useEffect } from \"react\";\nimport { useReCaptcha } from \"./use-re-captcha\";\ntype ReCaptchaProps = {\n action?: string;\n onVerify: (token: string) => void | Promise;\n onError?: (error: unknown) => void | Promise;\n};\n\n/** @deprecated Please use the `useRecaptcha` hook instead */\nexport function ReCaptcha({\n action,\n onVerify,\n onError\n}: ReCaptchaProps): null {\n const context = useReCaptcha();\n useEffect(function initRecaptchaToken() {\n async function executeRecaptcha(): Promise {\n try {\n const result = await context.execute(action);\n if (result.isError) return onError?.(result.error);\n return onVerify(result.value);\n } catch (error) {\n return onError?.(error);\n }\n }\n context.onLoad(executeRecaptcha);\n }, [action, context, onError, onVerify]);\n return null;\n}","/* eslint-disable import/prefer-default-export */\nimport { useContext } from \"react\";\nimport { RecaptchaContext, RecaptchaContextType } from \"./re-captcha-provider\";\nexport type UseReCaptcha = {\n /**\n * Used to manually trigger an audit of the current session.\n *\n * Returns a token that can be sent to the server to determine the user's trust score.\n *\n * @example\n * const reCaptcha = useReCaptcha(\"Login-Form-Submit\");\n *\n * function handleSubmit(): Promise {\n * try {\n * const result = await reCaptcha.execute();\n * // If an action was not passed to useReCaptcha we could pass one now\n * // reCaptcha.execute(\"Login-Form-Submit\")\n * if(result.isError) return await logException(result.error)\n * await fetch(url, {\n * method: \"POST\",\n * data: JSON.stringify({\n * reCaptchaToken: result.value\n * })\n * })\n * } catch(error) {\n * await logException(error)\n * }\n * }\n */\n execute: RecaptchaContextType[\"execute\"];\n onLoad: RecaptchaContextType[\"onLoad\"];\n};\nexport function useReCaptcha(): UseReCaptcha {\n const recaptcha = useContext(RecaptchaContext);\n if (!recaptcha) {\n throw new Error('\"useReCaptcha\" can only be used within a ');\n }\n return recaptcha;\n}"],"names":["RecaptchaDisclaimer","anchorProps","className","rest","span","clsx","data-sentry-component","data-sentry-source-file","br","a","href","rel","target","RecaptchaContext","ReCaptchaProvider","recaptchaSiteKey","local","development","test","production","env","isPreflight","current","scriptId","createContext","onExecute","onLoad","onError","action","useEnterprise","language","children","instanceRef","useRef","subs","Set","useCallback","cb","add","execute","error","Error","logException","isError","defaultAction","value","handleLoad","ref","window","grecaptcha","enterprise","ready","forEach","sub","clear","handleError","handleUnload","nodeBadge","document","querySelector","parentNode","body","removeChild","js","removeEventListener","useEffect","script","addEventListener","url","URL","searchParams","append","createElement","id","src","head","appendChild","useMemo","Provider","data-sentry-element","ReCaptcha","onVerify","context","useReCaptcha","executeRecaptcha","result","recaptcha","useContext"],"sourceRoot":""}