{"version":3,"file":"MainLayout-CgwJMSg1.js","sources":["../../../node_modules/@heroicons/react/24/solid/esm/ArrowLongLeftIcon.js","../../../node_modules/@heroicons/react/24/solid/esm/HomeIcon.js","../../../node_modules/@marsidev/react-turnstile/dist/index.mjs","../../../resources/js/Components/TurnstileWidget.tsx","../../../resources/js/Layouts/MainLayout.tsx"],"sourcesContent":["import * as React from \"react\";\nfunction ArrowLongLeftIcon({\n title,\n titleId,\n ...props\n}, svgRef) {\n return /*#__PURE__*/React.createElement(\"svg\", Object.assign({\n xmlns: \"http://www.w3.org/2000/svg\",\n viewBox: \"0 0 24 24\",\n fill: \"currentColor\",\n \"aria-hidden\": \"true\",\n \"data-slot\": \"icon\",\n ref: svgRef,\n \"aria-labelledby\": titleId\n }, props), title ? /*#__PURE__*/React.createElement(\"title\", {\n id: titleId\n }, title) : null, /*#__PURE__*/React.createElement(\"path\", {\n fillRule: \"evenodd\",\n d: \"M7.28 7.72a.75.75 0 0 1 0 1.06l-2.47 2.47H21a.75.75 0 0 1 0 1.5H4.81l2.47 2.47a.75.75 0 1 1-1.06 1.06l-3.75-3.75a.75.75 0 0 1 0-1.06l3.75-3.75a.75.75 0 0 1 1.06 0Z\",\n clipRule: \"evenodd\"\n }));\n}\nconst ForwardRef = /*#__PURE__*/ React.forwardRef(ArrowLongLeftIcon);\nexport default ForwardRef;","import * as React from \"react\";\nfunction HomeIcon({\n title,\n titleId,\n ...props\n}, svgRef) {\n return /*#__PURE__*/React.createElement(\"svg\", Object.assign({\n xmlns: \"http://www.w3.org/2000/svg\",\n viewBox: \"0 0 24 24\",\n fill: \"currentColor\",\n \"aria-hidden\": \"true\",\n \"data-slot\": \"icon\",\n ref: svgRef,\n \"aria-labelledby\": titleId\n }, props), title ? /*#__PURE__*/React.createElement(\"title\", {\n id: titleId\n }, title) : null, /*#__PURE__*/React.createElement(\"path\", {\n d: \"M11.47 3.841a.75.75 0 0 1 1.06 0l8.69 8.69a.75.75 0 1 0 1.06-1.061l-8.689-8.69a2.25 2.25 0 0 0-3.182 0l-8.69 8.69a.75.75 0 1 0 1.061 1.06l8.69-8.689Z\"\n }), /*#__PURE__*/React.createElement(\"path\", {\n d: \"m12 5.432 8.159 8.159c.03.03.06.058.091.086v6.198c0 1.035-.84 1.875-1.875 1.875H15a.75.75 0 0 1-.75-.75v-4.5a.75.75 0 0 0-.75-.75h-3a.75.75 0 0 0-.75.75V21a.75.75 0 0 1-.75.75H5.625a1.875 1.875 0 0 1-1.875-1.875v-6.198a2.29 2.29 0 0 0 .091-.086L12 5.432Z\"\n }));\n}\nconst ForwardRef = /*#__PURE__*/ React.forwardRef(HomeIcon);\nexport default ForwardRef;","'use client';\nimport { jsx } from 'react/jsx-runtime';\nimport { forwardRef, useState, useEffect, useRef, useMemo, useCallback, useImperativeHandle } from 'react';\n\nconst Component = ({ as: Element = \"div\", ...props }, ref) => {\n return /* @__PURE__ */ jsx(Element, { ...props, ref });\n};\nconst Container = forwardRef(Component);\n\nconst SCRIPT_URL = \"https://challenges.cloudflare.com/turnstile/v0/api.js\";\nconst DEFAULT_SCRIPT_ID = \"cf-turnstile-script\";\nconst DEFAULT_CONTAINER_ID = \"cf-turnstile\";\nconst DEFAULT_ONLOAD_NAME = \"onloadTurnstileCallback\";\nconst checkElementExistence = (id) => !!document.getElementById(id);\nconst injectTurnstileScript = ({\n render = \"explicit\",\n onLoadCallbackName = DEFAULT_ONLOAD_NAME,\n scriptOptions: {\n nonce = \"\",\n defer = true,\n async = true,\n id = \"\",\n appendTo,\n onError,\n crossOrigin = \"\"\n } = {}\n}) => {\n const scriptId = id || DEFAULT_SCRIPT_ID;\n if (checkElementExistence(scriptId)) {\n return;\n }\n const script = document.createElement(\"script\");\n script.id = scriptId;\n script.src = `${SCRIPT_URL}?onload=${onLoadCallbackName}&render=${render}`;\n if (document.querySelector(`script[src=\"${script.src}\"]`)) {\n return;\n }\n script.defer = !!defer;\n script.async = !!async;\n if (nonce) {\n script.nonce = nonce;\n }\n if (crossOrigin) {\n script.crossOrigin = crossOrigin;\n }\n if (onError) {\n script.onerror = onError;\n }\n const parentEl = appendTo === \"body\" ? document.body : document.getElementsByTagName(\"head\")[0];\n parentEl.appendChild(script);\n};\nconst CONTAINER_STYLE_SET = {\n normal: {\n width: 300,\n height: 65\n },\n compact: {\n width: 130,\n height: 120\n },\n invisible: {\n width: 0,\n height: 0,\n overflow: \"hidden\"\n },\n interactionOnly: {\n width: \"fit-content\",\n height: \"auto\",\n display: \"flex\"\n }\n};\nfunction getTurnstileSizeOpts(size) {\n let result;\n if (size !== \"invisible\") {\n result = size;\n }\n return result;\n}\n\nfunction useObserveScript(scriptId = DEFAULT_SCRIPT_ID) {\n const [scriptLoaded, setScriptLoaded] = useState(false);\n useEffect(() => {\n const checkScriptExists = () => {\n if (checkElementExistence(scriptId)) {\n setScriptLoaded(true);\n }\n };\n const observer = new MutationObserver(checkScriptExists);\n observer.observe(document, { childList: true, subtree: true });\n checkScriptExists();\n return () => {\n observer.disconnect();\n };\n }, [scriptId]);\n return scriptLoaded;\n}\n\nconst Turnstile = forwardRef((props, ref) => {\n const {\n scriptOptions,\n options = {},\n siteKey,\n onWidgetLoad,\n onSuccess,\n onExpire,\n onError,\n onBeforeInteractive,\n onAfterInteractive,\n onUnsupported,\n onLoadScript,\n id,\n style,\n as = \"div\",\n injectScript = true,\n ...divProps\n } = props;\n const widgetSize = options.size || \"normal\";\n const [containerStyle, setContainerStyle] = useState(\n options.execution === \"execute\" ? CONTAINER_STYLE_SET.invisible : options.appearance === \"interaction-only\" ? CONTAINER_STYLE_SET.interactionOnly : CONTAINER_STYLE_SET[widgetSize]\n );\n const containerRef = useRef(null);\n const firstRendered = useRef(false);\n const [turnstileLoaded, setTurnstileLoaded] = useState(false);\n const widgetId = useRef();\n const widgetSolved = useRef(false);\n const containerId = id || DEFAULT_CONTAINER_ID;\n const scriptId = injectScript ? scriptOptions?.id || `${DEFAULT_SCRIPT_ID}__${containerId}` : scriptOptions?.id || DEFAULT_SCRIPT_ID;\n const scriptLoaded = useObserveScript(scriptId);\n const onLoadCallbackName = scriptOptions?.onLoadCallbackName ? `${scriptOptions.onLoadCallbackName}__${containerId}` : `${DEFAULT_ONLOAD_NAME}__${containerId}`;\n const renderConfig = useMemo(\n () => ({\n sitekey: siteKey,\n action: options.action,\n cData: options.cData,\n callback: (token) => {\n widgetSolved.current = true;\n onSuccess?.(token);\n },\n \"error-callback\": onError,\n \"expired-callback\": onExpire,\n \"before-interactive-callback\": onBeforeInteractive,\n \"after-interactive-callback\": onAfterInteractive,\n \"unsupported-callback\": onUnsupported,\n theme: options.theme || \"auto\",\n language: options.language || \"auto\",\n tabindex: options.tabIndex,\n \"response-field\": options.responseField,\n \"response-field-name\": options.responseFieldName,\n size: getTurnstileSizeOpts(widgetSize),\n retry: options.retry || \"auto\",\n \"retry-interval\": options.retryInterval || 8e3,\n \"refresh-expired\": options.refreshExpired || \"auto\",\n execution: options.execution || \"render\",\n appearance: options.appearance || \"always\"\n }),\n [\n siteKey,\n options,\n onSuccess,\n onError,\n onExpire,\n widgetSize,\n onBeforeInteractive,\n onAfterInteractive,\n onUnsupported\n ]\n );\n const renderConfigStringified = useMemo(() => JSON.stringify(renderConfig), [renderConfig]);\n const checkIfTurnstileLoaded = useCallback(() => {\n return typeof window !== \"undefined\" && !!window.turnstile;\n }, []);\n useImperativeHandle(\n ref,\n () => {\n const { turnstile } = window;\n return {\n getResponse() {\n if (!turnstile?.getResponse || !widgetId.current || !checkIfTurnstileLoaded()) {\n console.warn(\"Turnstile has not been loaded\");\n return;\n }\n return turnstile.getResponse(widgetId.current);\n },\n async getResponsePromise(timeout = 3e4, retry = 100) {\n return new Promise((resolve, reject) => {\n let timeoutId;\n const checkLoaded = async () => {\n if (widgetSolved.current && window.turnstile && widgetId.current) {\n try {\n const token = window.turnstile.getResponse(widgetId.current);\n if (timeoutId)\n clearTimeout(timeoutId);\n if (token) {\n return resolve(token);\n }\n return reject(new Error(\"No response received\"));\n } catch (error) {\n if (timeoutId)\n clearTimeout(timeoutId);\n console.warn(\"Failed to get response\", error);\n return reject(new Error(\"Failed to get response\"));\n }\n }\n if (!timeoutId) {\n timeoutId = setTimeout(() => {\n if (timeoutId)\n clearTimeout(timeoutId);\n reject(new Error(\"Timeout\"));\n }, timeout);\n }\n await new Promise((resolve2) => setTimeout(resolve2, retry));\n await checkLoaded();\n };\n checkLoaded();\n });\n },\n reset() {\n if (!turnstile?.reset || !widgetId.current || !checkIfTurnstileLoaded()) {\n console.warn(\"Turnstile has not been loaded\");\n return;\n }\n if (options.execution === \"execute\") {\n setContainerStyle(CONTAINER_STYLE_SET.invisible);\n }\n try {\n console.log(\"resetting...\");\n widgetSolved.current = false;\n turnstile.reset(widgetId.current);\n } catch (error) {\n console.warn(`Failed to reset Turnstile widget ${widgetId}`, error);\n }\n },\n remove() {\n if (!turnstile?.remove || !widgetId.current || !checkIfTurnstileLoaded()) {\n console.warn(\"Turnstile has not been loaded\");\n return;\n }\n setContainerStyle(CONTAINER_STYLE_SET.invisible);\n widgetSolved.current = false;\n turnstile.remove(widgetId.current);\n widgetId.current = null;\n },\n render() {\n if (!turnstile?.render || !containerRef.current || !checkIfTurnstileLoaded() || widgetId.current) {\n console.warn(\"Turnstile has not been loaded or widget already rendered\");\n return;\n }\n const id2 = turnstile.render(containerRef.current, renderConfig);\n widgetId.current = id2;\n if (options.execution !== \"execute\") {\n setContainerStyle(CONTAINER_STYLE_SET[widgetSize]);\n }\n return id2;\n },\n execute() {\n if (options.execution !== \"execute\") {\n return;\n }\n if (!turnstile?.execute || !containerRef.current || !widgetId.current || !checkIfTurnstileLoaded()) {\n console.warn(\"Turnstile has not been loaded or widget has not been rendered\");\n return;\n }\n turnstile.execute(containerRef.current, renderConfig);\n setContainerStyle(CONTAINER_STYLE_SET[widgetSize]);\n },\n isExpired() {\n if (!turnstile?.isExpired || !widgetId.current || !checkIfTurnstileLoaded()) {\n console.warn(\"Turnstile has not been loaded\");\n return;\n }\n return turnstile.isExpired(widgetId.current);\n }\n };\n },\n [\n widgetId,\n options.execution,\n widgetSize,\n renderConfig,\n containerRef,\n checkIfTurnstileLoaded,\n turnstileLoaded\n ]\n );\n useEffect(() => {\n window[onLoadCallbackName] = () => setTurnstileLoaded(true);\n return () => {\n delete window[onLoadCallbackName];\n };\n }, [onLoadCallbackName]);\n useEffect(() => {\n if (injectScript && !turnstileLoaded) {\n injectTurnstileScript({\n onLoadCallbackName,\n scriptOptions: {\n ...scriptOptions,\n id: scriptId\n }\n });\n }\n }, [injectScript, turnstileLoaded, onLoadCallbackName, scriptOptions, scriptId]);\n useEffect(() => {\n if (scriptLoaded && !turnstileLoaded && window.turnstile) {\n setTurnstileLoaded(true);\n }\n }, [turnstileLoaded, scriptLoaded]);\n useEffect(() => {\n if (!siteKey) {\n console.warn(\"sitekey was not provided\");\n return;\n }\n if (!scriptLoaded || !containerRef.current || !turnstileLoaded || firstRendered.current) {\n return;\n }\n const id2 = window.turnstile.render(containerRef.current, renderConfig);\n widgetId.current = id2;\n firstRendered.current = true;\n }, [scriptLoaded, siteKey, renderConfig, firstRendered, turnstileLoaded]);\n useEffect(() => {\n if (!window.turnstile)\n return;\n if (containerRef.current && widgetId.current) {\n if (checkElementExistence(widgetId.current)) {\n window.turnstile.remove(widgetId.current);\n }\n const newWidgetId = window.turnstile.render(containerRef.current, renderConfig);\n widgetId.current = newWidgetId;\n firstRendered.current = true;\n }\n }, [renderConfigStringified, siteKey]);\n useEffect(() => {\n if (!window.turnstile)\n return;\n if (!widgetId.current)\n return;\n if (!checkElementExistence(widgetId.current))\n return;\n onWidgetLoad?.(widgetId.current);\n return () => {\n if (widgetId.current && window.turnstile)\n window.turnstile.remove(widgetId.current);\n };\n }, [widgetId, onWidgetLoad]);\n useEffect(() => {\n setContainerStyle(\n options.execution === \"execute\" ? CONTAINER_STYLE_SET.invisible : renderConfig.appearance === \"interaction-only\" ? CONTAINER_STYLE_SET.interactionOnly : CONTAINER_STYLE_SET[widgetSize]\n );\n }, [options.execution, widgetSize, renderConfig.appearance]);\n useEffect(() => {\n if (!scriptLoaded || typeof onLoadScript !== \"function\")\n return;\n onLoadScript();\n }, [scriptLoaded, onLoadScript]);\n return /* @__PURE__ */ jsx(\n Container,\n {\n ref: containerRef,\n as,\n id: containerId,\n style: { ...containerStyle, ...style },\n ...divProps\n }\n );\n});\nTurnstile.displayName = \"Turnstile\";\n\nexport { DEFAULT_CONTAINER_ID, DEFAULT_ONLOAD_NAME, DEFAULT_SCRIPT_ID, SCRIPT_URL, Turnstile };\n","import { usePage } from \"@inertiajs/react\";\nimport { Turnstile } from \"@marsidev/react-turnstile\";\nimport React, { ReactNode } from \"react\";\nimport axios from \"@/Utils/axios\";\nimport { useDispatch, useSelector } from \"react-redux\";\nimport { hideTurnstile, RootState } from \"@/Reducers/store\";\nimport Modal from \"@/Components/Modal\";\n\ntype Props = {\n children: ReactNode;\n};\n\nexport const TurnstileWidget = ({ children }: Props) => {\n // @ts-expect-error Know prop should be buried here\n const siteKey = usePage().props.cf?.site_key;\n\n const showTurnstile = useSelector(\n (state: RootState) => state.showCloudflareTurnstile.value,\n );\n const dispatch = useDispatch();\n\n const validateToken = async (token: string): Promise => {\n const response = await axios.post(route(\"validate_turnstile_widget\"), {\n token: token,\n });\n\n return response.data.success;\n };\n\n return (\n <>\n {children}\n\n {siteKey && (\n <>\n {\n dispatch(hideTurnstile());\n }}\n title=\"One moment please\"\n >\n

\n We're checking if the site connection is\n secure.\n

\n\n

\n Once you complete the captcha, please retry your\n request.\n

\n\n {\n const valid = await validateToken(token);\n\n if (valid) {\n dispatch(hideTurnstile());\n }\n }}\n />\n \n \n )}\n \n );\n};\n","import React, { Fragment, ReactNode } from \"react\";\nimport { Menu, Popover, Transition } from \"@headlessui/react\";\nimport {\n ArrowLongLeftIcon,\n ChevronDownIcon,\n HomeIcon,\n} from \"@heroicons/react/24/solid\";\nimport { Bars3Icon, XMarkIcon } from \"@heroicons/react/24/outline\";\nimport Footer from \"./Components/Footer.jsx\";\nimport { Head, InertiaLinkProps, usePage } from \"@inertiajs/react\";\nimport Link from \"@/Components/BaseLink.jsx\";\nimport MainHeader from \"./Components/MainHeader.jsx\";\nimport Container from \"@/Components/Container.jsx\";\nimport TenantLogo from \"@/Components/TenantLogo.jsx\";\nimport { connect } from \"react-redux\";\nimport { TurnstileWidget } from \"@/Components/TurnstileWidget\";\nimport { createPortal } from \"react-dom\";\nimport FlashToast from \"@/Components/FlashToast.tsx\";\n\nconst userNavigation: Item[] = [\n { name: \"My Account\", href: route(\"my_account.profile\") },\n { name: \"Help\", href: \"https://docs.myswimmingclub.uk/\", external: true },\n { name: \"Sign out\", href: route(\"logout\"), method: \"post\" },\n];\n\nfunction classNames(...classes) {\n return classes.filter(Boolean).join(\" \");\n}\n\ninterface Props {\n title: string;\n subtitle?: string;\n children: ReactNode;\n breadcrumbs?: {\n name: string;\n route: string;\n routeParams?: never;\n }[];\n buttons: ReactNode;\n hideHeader?: boolean;\n mainClassName?: string;\n help?: string;\n}\n\ntype Item = {\n name: string;\n href: string;\n external?: boolean;\n method?: InertiaLinkProps[\"method\"];\n};\n\nconst MainLayout: React.FC = ({\n title,\n subtitle,\n children,\n breadcrumbs,\n buttons,\n hideHeader = false,\n mainClassName = \"min-h-screen py-10\",\n help,\n}) => {\n // @ts-expect-error Know prop exists and is nullable\n const userObject = usePage().props.auth.user;\n\n // @ts-expect-error Know prop exists\n const navigation = usePage().props.tenant.menu;\n\n const url = usePage().url;\n\n const user = userObject\n ? {\n name: `${userObject.Forename} ${userObject.Surname}`,\n email: userObject.EmailAddress,\n imageUrl: userObject.gravatar_url,\n }\n : null;\n\n return (\n <>\n {/*\n This example requires updating your template:\n\n ```\n \n \n ```\n */}\n {/* Fall back to the layout title if no page title is set */}\n \n
\n
\n \n \n
\n
\n \n \n \n
\n \n {navigation.map((item) => {\n if (item.external) {\n return (\n \n {item.name}\n \n );\n }\n if (item.children?.length > 0) {\n return (\n // \n // {item.name}\n // \n\n \n
\n \n \n Open {item.name}{\" \"}\n menu\n \n {item.name}{\" \"}\n \n \n
\n \n \n {item.children.map(\n (item) => (\n \n {({\n active,\n }) => (\n \n {\n item.name\n }\n \n )}\n \n ),\n )}\n \n \n \n );\n }\n return (\n \n {item.name}\n \n );\n })}\n \n
\n {/*
\n
\n \n
\n
\n \n
\n \n
\n
\n
*/}\n
\n {/* Mobile menu button */}\n \n \n Open main menu\n \n \n \n
\n {createPortal(\n \n
\n \n \n \n\n \n \n
\n
\n
\n
\n
\n \n
\n
\n \n \n Close\n menu\n \n \n \n
\n
\n
\n {navigation.map(\n (item) => {\n if (\n item\n .children\n ?.length >\n 0\n ) {\n return (\n // \n // {item.name}\n // \n\n \n \n \n Open{\" \"}\n {\n item.name\n }{\" \"}\n menu\n \n {\n item.name\n }{\" \"}\n \n \n \n \n {item.children.map(\n (\n item,\n ) => (\n \n {({\n active,\n }) => (\n \n {\n item.name\n }\n \n )}\n \n ),\n )}\n \n \n \n );\n }\n return (\n \n {\n item.name\n }\n \n );\n },\n )}\n
\n
\n {user && (\n
\n
\n
\n \n
\n
\n
\n {\n user.name\n }\n
\n
\n {\n user.email\n }\n
\n
\n {/* We don't have notifications yet */}\n {/* \n \n View\n notifications\n \n \n */}\n
\n
\n {userNavigation.map(\n (\n item,\n idx,\n ) => (\n \n {\n item.name\n }\n \n ),\n )}\n
\n
\n )}\n
\n
\n \n \n
\n
,\n document.body,\n )}\n
\n {/* We don't have notifications yet */}\n {/* \n \n View notifications\n \n \n */}\n\n {/* Profile dropdown */}\n {user && (\n \n
\n \n \n Open user menu\n \n \n \n
\n \n \n {userNavigation.map(\n (item, idx) => (\n \n {({ active }) => (\n \n {item.name}\n \n )}\n \n ),\n )}\n \n \n \n )}\n
\n
\n
\n\n {breadcrumbs && (\n \n
\n \n
\n
\n )}\n
\n\n \n
\n {/* Page header */}\n {!hideHeader && (\n \n \n \n )}\n\n {children}\n
\n
\n
\n\n \n\n