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AAhB,aAAAA,EAAAA,EAAUyD,EAAO5C,QACrC,C,EAAAwC,EAASI,EAAOvC,Q,OAEvB,OADOL,EAAAA,EAAAA,OACA,C,EAAAb,aAAAA,EAAAA,EAAUa,I,oBAErB,KARe2C,MAAAA,KAAAA,U,CAUfF,EAAQvD,Q,kBAVOyD,EAAAA,MAAAA,KAAAA,U,GAWjB,GACA,CAACvD,EAAQqD,EAAStD,EAASqD,IAGtB,IACT,C,4ICEgBE,C,YAjCW,O,IAC4B,OAgChD,SAASA,IACd,IAAMG,GAAYC,EAAAA,EAAAA,YAAWzE,EAAAA,kBAE7B,IAAKwE,EACH,MAAM,IAAI5C,MACR,gEAIJ,OAAO4C,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\";\n","/* eslint-disable import/prefer-default-export */\nimport clsx from \"clsx\";\nimport React, { HTMLAttributes } from \"react\";\n\ntype RecaptchaDisclaimerProps = HTMLAttributes & {\n anchorProps?: HTMLAttributes;\n};\n\nexport function RecaptchaDisclaimer({\n anchorProps,\n className,\n ...rest\n}: RecaptchaDisclaimerProps) {\n return (\n \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 );\n}\n","import React, {\n createContext,\n ReactNode,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n} from \"react\";\nimport { logException } from \"@wss/error-tracking\";\nimport { Throwable } from \"@wss/error-tracking/throwable\";\nimport { env } from \"~/common/Environment\";\n\ntype Recaptcha = {\n execute: (key: string, opts?: { action?: string }) => Promise;\n ready: (cb: () => void) => void;\n};\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 =\n recaptchaSiteKeys[env.isPreflight ? \"development\" : env.current];\nconst scriptId = \"google-recaptcha-v3\";\n\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};\n\nexport const RecaptchaContext = createContext(\n null\n);\n\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\n const onLoad: RecaptchaContextType[\"onLoad\"] = useCallback(\n function handleOnLoad(cb: () => void): void {\n if (!instanceRef.current) {\n subs.current.add(cb);\n return;\n }\n cb();\n },\n []\n );\n\n const execute: RecaptchaContextType[\"execute\"] = useCallback(\n async function onExecute(\n action?: string\n ): ReturnType {\n if (!instanceRef.current) {\n const error = new Error(\"Google Recaptcha has not been loaded\");\n await logException(error);\n return { isError: true, error };\n }\n\n try {\n const result = await instanceRef.current.execute(recaptchaSiteKey, {\n action: action ?? defaultAction,\n });\n return { isError: false, value: result };\n } catch (error) {\n await logException(error);\n return { isError: true, error };\n }\n },\n [defaultAction]\n );\n\n const handleLoad = useCallback(\n async function onLoad(): Promise {\n if (!window.grecaptcha) {\n await logException(new Error(\"Recaptcha was no able to load\"));\n return;\n }\n\n const ref: Recaptcha = useEnterprise\n ? window.grecaptcha.enterprise\n : window.grecaptcha;\n\n ref.ready(function handleRecaptchaReady() {\n instanceRef.current = ref;\n subs.current.forEach((sub) => sub());\n subs.current.clear();\n });\n },\n [useEnterprise]\n );\n\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\n const handleUnload = useCallback(\n function onUnload() {\n const nodeBadge = document.querySelector(\".grecaptcha-badge\");\n if (nodeBadge && nodeBadge.parentNode) {\n document.body.removeChild(nodeBadge.parentNode);\n }\n\n instanceRef.current = null;\n\n const js = document.querySelector(`#${scriptId}`);\n js?.removeEventListener(\"load\", handleLoad);\n js?.removeEventListener(\"error\", handleError);\n },\n [handleError, handleLoad]\n );\n\n useEffect(\n 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\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\n document.head.appendChild(js);\n\n return handleUnload;\n },\n [handleError, handleLoad, handleUnload, language, useEnterprise]\n );\n\n const value = useMemo(() => ({ execute, onLoad }), [execute, onLoad]);\n\n return (\n \n {children}\n \n );\n}\n","/* eslint-disable import/prefer-default-export */\nimport { useEffect } from \"react\";\nimport { useReCaptcha } from \"./use-re-captcha\";\n\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({ action, onVerify, onError }: ReCaptchaProps): null {\n const context = useReCaptcha();\n\n useEffect(\n 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\n context.onLoad(executeRecaptcha);\n },\n [action, context, onError, onVerify]\n );\n\n return null;\n}\n","/* eslint-disable import/prefer-default-export */\nimport { useContext } from \"react\";\nimport { RecaptchaContext, RecaptchaContextType } from \"./re-captcha-provider\";\n\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};\n\nexport function useReCaptcha(): UseReCaptcha {\n const recaptcha = useContext(RecaptchaContext);\n\n if (!recaptcha) {\n throw new Error(\n '\"useReCaptcha\" can only be used within a '\n );\n }\n\n return recaptcha;\n}\n"],"names":["RecaptchaDisclaimer","anchorProps","className","rest","span","clsx","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","ReCaptcha","onVerify","context","useReCaptcha","executeRecaptcha","result","recaptcha","useContext"],"sourceRoot":""}