{"version":3,"file":"static/js/PublicAppContainer.3e7c68a0.js","sources":["webpack://@jotforminc/portal/./src/modules/containers/PublicAppContainer.js","webpack://@jotforminc/portal/./src/assets/icon_share_iOS.svg","webpack://@jotforminc/portal/../../../../src/icons/forms-files/form-pencil-filled.svg","webpack://@jotforminc/portal/./src/assets/icon_unreachableSentbox.svg","webpack://@jotforminc/portal/./src/assets/icon_emptyCart.svg","webpack://@jotforminc/portal/../../../../src/icons/brand/facebook-filled.svg","webpack://@jotforminc/portal/../../../../src/icons/brand/twitter.svg","webpack://@jotforminc/portal/../../../../src/icons/brand/whatsapp.svg","webpack://@jotforminc/portal/../../../../src/icons/finance/basket-shopping-filled.svg","webpack://@jotforminc/portal/./src/assets/backsoon.svg","webpack://@jotforminc/portal/./src/modules/PublicApp/scPublicApp.js","webpack://@jotforminc/portal/./src/modules/PublicApp/Modals/A2HSModal/ScA2HSModal.js","webpack://@jotforminc/portal/./src/modules/PublicApp/Modals/A2HSModal/index.js","webpack://@jotforminc/portal/./src/modules/PublicApp/FormItem/InlineCtxMenu/ScMobileCtxMenu.js","webpack://@jotforminc/portal/./src/modules/PublicApp/MobileCtxMenu.js","webpack://@jotforminc/portal/./src/components/AppProgressBar/ScAppProgressBar.js","webpack://@jotforminc/portal/./src/modules/PublicApp/ProgressBar.js","webpack://@jotforminc/portal/./src/components/AppProgressBar/index.js","webpack://@jotforminc/portal/./src/modules/PublicApp/TopBar/ScTopBar.js","webpack://@jotforminc/portal/../../libs/overflowable-list/src/index.tsx","webpack://@jotforminc/portal/./src/modules/PublicApp/TopBar/PageLink.js","webpack://@jotforminc/portal/./src/modules/PublicApp/TopBar/ScNavigationBar.js","webpack://@jotforminc/portal/./src/modules/PublicApp/ProductCartBadge/ScCart.js","webpack://@jotforminc/portal/./src/modules/PublicApp/ProductCartBadge/index.js","webpack://@jotforminc/portal/./src/modules/PublicApp/DonateNowBadge/ScDonateNowBadge.js","webpack://@jotforminc/portal/./src/modules/PublicApp/DonateNowBadge/index.js","webpack://@jotforminc/portal/./src/modules/PublicApp/TopBar/ScNavigationPanel.js","webpack://@jotforminc/portal/./src/modules/PublicApp/TopBar/NavigationPanelItem.js","webpack://@jotforminc/portal/./src/modules/PublicApp/TopBar/NavigationPanel.js","webpack://@jotforminc/portal/./src/components/PortalLoginFlow/scPortalLoginFlow.js","webpack://@jotforminc/portal/./src/components/PortalAccountBox/AccountBoxLinkRenderer.js","webpack://@jotforminc/portal/./src/components/PortalAccountBox/GuestShoppingAccountBox.js","webpack://@jotforminc/portal/./src/components/PortalAccountBox/ContinueAsFlow.js","webpack://@jotforminc/portal/./src/components/PortalAccountBox/index.js","webpack://@jotforminc/portal/./src/modules/PublicApp/TopBar/NavigationBar.js","webpack://@jotforminc/portal/./src/modules/PublicApp/TopBar/index.js","webpack://@jotforminc/portal/./src/modules/PublicApp/ScPageContentWrapper.js","webpack://@jotforminc/portal/./src/modules/PublicApp/DividerItem/index.js","webpack://@jotforminc/portal/./src/components/ProductListForm/ProductListField.js","webpack://@jotforminc/portal/./src/modules/PublicApp/ProductListItem/index.js","webpack://@jotforminc/portal/./src/modules/PublicApp/CardItem/styled.js","webpack://@jotforminc/portal/./src/modules/PublicApp/CardItem/index.js","webpack://@jotforminc/portal/./src/modules/PublicApp/List/helper.js","webpack://@jotforminc/portal/./src/modules/PublicApp/List/index.js","webpack://@jotforminc/portal/./src/modules/PublicApp/ImageField/ScImageField.js","webpack://@jotforminc/portal/./src/modules/PublicApp/ImageField/index.js","webpack://@jotforminc/portal/./src/utils/getItemComponentByTypeForApp.js","webpack://@jotforminc/portal/./src/modules/PublicApp/AppItem/index.js","webpack://@jotforminc/portal/./src/modules/PublicApp/withLinkElement.js","webpack://@jotforminc/portal/./src/modules/PublicApp/PublicAppItemContainer/PublicAppItem.js","webpack://@jotforminc/portal/./src/modules/PublicApp/PublicAppItemContainer/index.js","webpack://@jotforminc/portal/./src/components/Items/AppFooter/ScAppFooter.js","webpack://@jotforminc/portal/./src/components/Items/AppFooter/index.js","webpack://@jotforminc/portal/./src/modules/PublicApp/AppStyle.js","webpack://@jotforminc/portal/./src/modules/PublicApp/AppPreview.js","webpack://@jotforminc/portal/./src/modules/PublicApp/AppRouter.js","webpack://@jotforminc/portal/./src/modules/PublicApp/ProductRenderer/Renderers/FormRenderer.js","webpack://@jotforminc/portal/./src/modules/PublicApp/ProductRenderer/Renderers/ReportRenderer.js","webpack://@jotforminc/portal/./src/modules/PublicApp/ProductRenderer/Renderers/UnreachableSentbox.js","webpack://@jotforminc/portal/./src/modules/PublicApp/ProductRenderer/Renderers/SentboxRenderer.js","webpack://@jotforminc/portal/./src/modules/PublicApp/ProductRenderer/Renderers/SignRenderer.js","webpack://@jotforminc/portal/./src/modules/PublicApp/ProductRenderer/constants.js","webpack://@jotforminc/portal/./src/modules/PublicApp/ProductRenderer/RendererComponent.js","webpack://@jotforminc/portal/./src/modules/PublicApp/ProductRenderer/Renderers/constants.js","webpack://@jotforminc/portal/./src/modules/Builder/styles/scSteps.js","webpack://@jotforminc/portal/./src/modules/PublicApp/ScreenRenderer/ScreenTopBar.js","webpack://@jotforminc/portal/./src/modules/PublicApp/ProductRenderer/index.js","webpack://@jotforminc/portal/./src/modules/PublicApp/OrderNow/ScOrderNowButton.js","webpack://@jotforminc/portal/./src/modules/PublicApp/OrderNow/index.js","webpack://@jotforminc/portal/./src/modules/PublicApp/ScreenRenderer/index.js","webpack://@jotforminc/portal/./src/modules/PublicApp/PageRenderer.js","webpack://@jotforminc/portal/./src/modules/PublicApp/CheckoutScreen/ScCompleteScreen.js","webpack://@jotforminc/portal/./src/modules/PublicApp/CheckoutScreen/StoreCompleteScreen.js","webpack://@jotforminc/portal/./src/modules/PublicApp/CheckoutScreen/DonationCompleteScreen.js","webpack://@jotforminc/portal/./src/modules/PublicApp/CheckoutScreen/ScCheckoutScreen.js","webpack://@jotforminc/portal/./src/modules/PublicApp/CheckoutScreen/index.js","webpack://@jotforminc/portal/../../libs/portal-components/src/components/AddToCart.js","webpack://@jotforminc/portal/./src/modules/PublicApp/ProductCart/Cart/CartOption.js","webpack://@jotforminc/portal/./src/modules/PublicApp/ProductCart/Cart/CartItemOptionRenderer.js","webpack://@jotforminc/portal/./src/modules/PublicApp/ProductCart/Cart/CartItemActionButton.js","webpack://@jotforminc/portal/./src/modules/PublicApp/ProductCart/Cart/ScProductCartItem.js","webpack://@jotforminc/portal/./src/modules/PublicApp/ProductCart/Cart/CartItem.js","webpack://@jotforminc/portal/./src/components/Toaster/ShoppingNotification/utils.js","webpack://@jotforminc/portal/./src/modules/PublicApp/ProductCart/Cart/CartItemList.js","webpack://@jotforminc/portal/./src/modules/PublicApp/ProductCart/Cart/Carts.js","webpack://@jotforminc/portal/./src/modules/PublicApp/ProductCart/Cart/ScEmptyCart.js","webpack://@jotforminc/portal/./src/modules/PublicApp/OrderNow/ScOrderNowForScreen.js","webpack://@jotforminc/portal/./src/modules/PublicApp/OrderNow/OrderNowForScreen.js","webpack://@jotforminc/portal/./src/modules/PublicApp/ProductCart/Cart/index.js","webpack://@jotforminc/portal/./src/modules/PublicApp/ProductCart/Favorites/index.js","webpack://@jotforminc/portal/./src/modules/PublicApp/ProductCart/ScProductCart.js","webpack://@jotforminc/portal/./src/components/StoreUnavailable/ScStoreUnavailable.js","webpack://@jotforminc/portal/./src/components/StoreUnavailable/index.js","webpack://@jotforminc/portal/./src/modules/PublicApp/ProductCart/TabButton.js","webpack://@jotforminc/portal/./src/modules/PublicApp/ProductCart/index.js","webpack://@jotforminc/portal/./src/modules/PublicApp/ProductItemDetailsPage/ScDetailsPage.js","webpack://@jotforminc/portal/./src/modules/PublicApp/ProductItemDetailsPage/ActionButtons.js","webpack://@jotforminc/portal/./src/modules/PublicApp/ProductItemDetailsPage/index.js","webpack://@jotforminc/portal/./src/modules/PublicApp/PushNotificationPermission/index.js","webpack://@jotforminc/portal/./src/modules/PublicApp/AiAgent/ScAiAgent.js","webpack://@jotforminc/portal/./src/modules/PublicApp/AiAgent/index.js","webpack://@jotforminc/portal/./src/modules/PublicApp/index.js"],"sourcesContent":["import React, {\n useCallback, useEffect, useMemo, useRef, useState\n} from 'react';\nimport { func, string } from 'prop-types';\nimport { useDispatch, useSelector } from 'react-redux';\nimport { getAppPath } from '@jotforminc/router-bridge';\nimport { useTimeout, useEventListener } from '@jotforminc/hooks';\n\nimport { APP_MODES } from '../../constants';\nimport SELECTORS from '../../store/selectors';\n\nimport {\n fetchPortalAction,\n navigateToAction,\n setModeAction,\n setPWAStatusAction,\n trackEventAction,\n userChangeAction\n} from '../../store/actionCreators';\nimport { isYes, isInJotformKiosk } from '../../utils';\nimport { calculateDisabled } from '../../utils/hooks';\n\nimport BrowserParser from '../../utils/BrowserParser';\nimport { getQueryString } from '../../utils/navigation';\nimport {\n allSocialSharingUtmSources,\n checkPWAInstallation, getLastInstallationDate, isPWA, persistPWAInstallation\n} from '../PublicApp/utils';\nimport PublicApp from '../PublicApp';\nimport appConfig from '../../constants/appConfig';\n\nlet deferredPrompt;\n\n// eslint-disable-next-line max-statements\nconst PublicAppContainer = ({ appID, navigate }) => {\n const dispatch = useDispatch();\n\n const isInApp = useSelector(SELECTORS.isOpenedInApp);\n const isInstalled = useSelector(SELECTORS.isAppInstalled);\n const user = useSelector(SELECTORS.getUser);\n const appProperties = useSelector(SELECTORS.getAppInfoWithDefaults);\n\n const {\n id: storeAppID, redirectToApp, redirectedApp\n } = appProperties;\n\n // Disable Details\n const {\n isDisabledNow: isRedirectedAppDisabledNow,\n isDateVerySoon: redirectedAppWillDisableSoon\n } = calculateDisabled(redirectedApp);\n\n const isRedirectedAppSafe = useMemo(() => { // Dont redirect to apps which gonna be disabled very soon.\n return isYes(redirectToApp) && !isRedirectedAppDisabledNow && !redirectedAppWillDisableSoon;\n }, [redirectToApp, isRedirectedAppDisabledNow, redirectedAppWillDisableSoon]);\n\n const [appJustDisabled, setAppJustDisabled] = useState(false);\n const handleAppRedirection = useCallback(() => {\n const searchParams = getQueryString();\n const qs = searchParams ? `?${searchParams}` : '';\n navigate(`${getAppPath()}/${redirectedApp}${qs}`, { replace: true });\n }, [redirectedApp]);\n\n const handleSocialSharingRedirect = () => {\n const searchParams = new URLSearchParams(window.location.search);\n if (allSocialSharingUtmSources.includes(searchParams.get('utm_source'))) {\n window.history.pushState(null, null, `${getAppPath()}/${appID}`);\n }\n };\n\n const handleAppDisable = useCallback(() => {\n if (isRedirectedAppSafe) {\n handleAppRedirection();\n return;\n }\n setAppJustDisabled(true);\n }, [isRedirectedAppSafe, redirectedApp]);\n\n const { isDisabledNow: isAppDisabledNow, isTrashedNow: isAppTrashedNow } = calculateDisabled(storeAppID, handleAppDisable);\n\n useEffect(() => {\n if (isAppDisabledNow && isRedirectedAppSafe) {\n handleAppRedirection();\n }\n }, [isAppDisabledNow, isRedirectedAppSafe]);\n\n const isInBuilderPreview = window.location.href.includes('#preview');\n\n // TODO: move A2HS Modal logic into a different file\n const isInstalledRef = useRef();\n isInstalledRef.current = isInstalled; // This is a workaround to access updated value in timeouted fn\n\n const [activeModal, setActiveModal] = useState('');\n\n const setPublicApp = (isBuilder = false) => {\n dispatch(setModeAction(APP_MODES.public));\n if (storeAppID !== appID || isBuilder) {\n dispatch(fetchPortalAction(appID));\n }\n dispatch(setPWAStatusAction({ isOpenedInPWA: isPWA(), isPWAInstalled: checkPWAInstallation(appID) }));\n };\n\n useEffect(() => {\n setPublicApp();\n }, [appID]);\n\n useEffect(() => {\n if (user.username) {\n const isEmbedded = window.location.href.includes(appConfig.embeddedAppQS);\n const searchParams = new URLSearchParams(window.location.search);\n switch (true) {\n case isInBuilderPreview:\n dispatch(trackEventAction({ action: 'appPreviewed' }));\n return;\n case isEmbedded:\n dispatch(trackEventAction({ action: 'embeddedAppViewed' }));\n return;\n default:\n dispatch(trackEventAction({ action: 'appViewed', target: { utmSource: searchParams.get('utm_source') } }));\n }\n handleSocialSharingRedirect();\n }\n }, [user]);\n\n const handleAppInstalled = useCallback(() => {\n persistPWAInstallation(appID);\n dispatch(setPWAStatusAction({ isOpenedInPWA: isPWA(), isPWAInstalled: true }));\n dispatch(trackEventAction({ action: 'PWAInstalled' }));\n setActiveModal(false);\n }, [appID]);\n\n const isUnRecognizedIpad = BrowserParser.is('macOS') && window.navigator.maxTouchPoints > 2;\n const isIOS = BrowserParser.is('ios') || isUnRecognizedIpad;\n const isTablet = BrowserParser.is('tablet') || BrowserParser.is('mobile') || isUnRecognizedIpad;\n const makeModalChecks = useCallback(() => {\n let modalName;\n const currentlyInstalled = isInstalledRef.current;\n switch (true) {\n case deferredPrompt && !isInApp && !currentlyInstalled:\n modalName = 'promptableFirstTimeModal';\n break;\n case !deferredPrompt && !isInApp && !currentlyInstalled && isIOS:\n modalName = BrowserParser.is('safari') ? 'iOSModal' : 'iOSNotSafari';\n break;\n case !deferredPrompt && !isInApp && !currentlyInstalled && BrowserParser.is('android'):\n modalName = 'androidModal';\n break;\n case isTablet:\n modalName = 'regularModal';\n break;\n default:\n modalName = false;\n break;\n }\n\n if (currentlyInstalled || isInApp || isPWA() || isInBuilderPreview || isInJotformKiosk()) {\n modalName = false;\n }\n setActiveModal(modalName);\n }, []);\n\n const handleBeforeInstallPrompt = useCallback(e => {\n e.preventDefault();\n const lastInstallationDate = getLastInstallationDate(appID);\n if (lastInstallationDate) {\n const now = Date.now();\n const diff = now - lastInstallationDate;\n if (diff <= 5e3) {\n return false; // App is installed within 5 sec. This will guard immediate trigger of the beforeinstallprompt event after the installation.\n }\n }\n deferredPrompt = e;\n // if this fn is invoked it means the app is not installed yet or uninstalled.\n // Lets update LS value to show A2HS modal\n persistPWAInstallation(appID, false);\n\n makeModalChecks();\n }, [appID]);\n\n useEventListener('beforeinstallprompt', handleBeforeInstallPrompt);\n useEventListener('appinstalled', handleAppInstalled);\n useTimeout(makeModalChecks, 10000);\n\n // Handles after modal interaction: install/dismiss\n const handleOnPrompt = useCallback(() => {\n if (deferredPrompt) {\n deferredPrompt.prompt();\n // added for Chrome install prompter event tracking\n // one day, Safari?\n deferredPrompt.userChoice.then(choiceResult => {\n if (choiceResult.outcome === 'accepted') {\n dispatch(trackEventAction({ action: 'installPromptAccepted' }));\n } else {\n dispatch(trackEventAction({ action: 'installPromptDismissed' }));\n }\n });\n }\n }, []);\n\n const handleUserChanged = action => {\n const { user: changedUser } = action.payload;\n dispatch(userChangeAction(changedUser));\n };\n\n const handleNavigateToPage = action => {\n dispatch(navigateToAction({\n to: action.payload?.destinationType,\n pageID: action.payload?.pageID\n }));\n };\n\n const handleScrollSelectedItem = action => {\n const { itemID } = action.payload;\n const selectedItem = document.getElementById(itemID);\n\n if (!selectedItem) return;\n\n const scrollToCenter = element => {\n const { top, height } = element.getBoundingClientRect();\n const { scrollTop } = document.documentElement;\n const windowHeight = window.innerHeight;\n\n const targetPosition = top + scrollTop - (windowHeight / 2) + (height / 2);\n\n window.scrollTo({\n top: targetPosition,\n behavior: 'smooth'\n });\n };\n\n scrollToCenter(selectedItem);\n };\n\n useEventListener('message', message => {\n const { data: { action = {}, forJFApps } = {} } = message;\n\n switch (action.name) {\n case 'userChanged':\n if (forJFApps) handleUserChanged(action);\n break;\n case 'NAVIGATE_TO_PAGE':\n handleNavigateToPage(action);\n break;\n case 'SELECT_ITEM':\n handleScrollSelectedItem(action);\n break;\n case 'UPDATE_APP':\n setPublicApp(true);\n break;\n default:\n break;\n }\n });\n\n return (\n
\n {description(modalType)}\n
\n{t(`Login in to track your ${isDonationApp ? 'donations' : 'orders'}`)}
\n \n\n {t('New customer?')}\n \n
\n{userName}
\n{email}
\n\n {t('Use a different account?')}\n \n {t('Log in')}\n \n
\n{t('Spread Goodness & Share Your Support')}
\n{subscriptionPromptContent || fallbackContent}
\n